I'm testing a custom validation error message in Laravel 7.0. When I don't add an email address the message has to be: The data was not complete. but what I get is: The given data was invalid.
The request:
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class CreateMemberRequestRequest 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
*/
public function rules()
{
return [
'email' => 'required|email',
'name', 'first_name',
];
}
/**
* Get the error messages for the defined validation rules.
*
* @return array
*/
public function messages()
{
return [
'required' => 'The data was not complete',
'email.email' => 'This is not a valid email address',
];
}
/**
* Filters to be applied to the input.
*
* @return array
*/
public function filters()
{
return [
'email' => 'trim|lowercase',
'name' => 'trim|capitalize|escape'
];
}
}
The controller function: public function __invoke(CreateMemberRequestRequest $request)
Please help me out!
Aucun commentaire:
Enregistrer un commentaire