framework
framework copied to clipboard
[Request] Set custom error messages directly from a FormRequest class
Lets Say I have a FormRequest class like:
<?php namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class MyFormRequest extends FormRequest {
public function rules()
{
return [
'my_field' => 'rule'
];
}
public function messages()
{
return [
'my_field.rule' => 'Specific error message just for this request / field /rule'
];
}
public function authorize()
{
return true;
}
}
As you can see I added there a messages() method to specify any custom message that applies just to the request.
Is there any way to do that currently?
Regards, Marco
Same question.
Pull-Request to add this had been made.