我想在laravel5表单验证错误消息中设置自定义文件名。
我form validation request class
是
class PasswordRequest extends Request {
protected $rules = [
'old' => ['required'],
'new' => ['required','same:cnew'],
'cnew' => ['required']
];
/**
* 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 $this->rules;
}
}
在这里,旧的,新的和新的空时,错误消息将如下所示,
我想显示如下而不是上面的消息,
laravel5表单请求验证方法中怎么可能?
选项1:
您可以在resources / lang / en / validation.php中的Custom Validation Attributes'attributes '=> []下定义您的自定义属性,如下所示:
/*
|--------------------------------------------------------------------------
| Custom Validation Attributes
|--------------------------------------------------------------------------
|
| The following language lines are used to swap attribute place-holders
| with something more reader friendly such as E-Mail Address instead
| of "email". This simply helps us make messages a little cleaner.
|
*/
'attributes' => [
'old' =>'Old Paaword',
'new' =>'New password',
'cnew' =>'Confirmation password'
]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句