Do you mean an actual test? Like phpunit. Or just testing it in the browser
Aug 17, 2022
9
Level 10
How to test a rule?
Hi all,
I have a requestFile set this way:
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
class ProfileUpdateRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'first_name' => ['required', 'max:255', 'string'],
'last_name' => ['required', 'max:255', 'string'],
'email' => [
'required',
Rule::unique('users', 'email')->ignore($this->profile),
'email',
],
'password' => ['nullable'],
'business_name' => ['nullable', 'max:255', 'string'],
'postcode' => ['nullable', 'max:255', 'string'],
'business_phone' => ['nullable', 'max:255', 'string'],
'vat_number' => ['nullable', 'max:255', 'string'],
'active' => ['required', 'max:255', 'string'],
'avatar' => ['nullable', 'image', 'max:1024'],
'roles' => 'array',
];
}
}
The request never reaches my controller so I assume that there is an error in the request itself. Is there a way to output errors in this case please from this file as I am not getting any output after the request.
Thanks
Level 102
Or use dd inside the form request to inspect your variables
1 like
Please or to participate in this conversation.