根据文档,error messages
可以在lang/en/validation.php
内自定义,但我收到的错误消息不在文件中:
The password confirmation does not match.
当validation
失败时,我收到错误消息,因为$request->password_confirmation
与$request->password
:不同
$request->validate([
'password' => ['required', 'confirmed', RulesPassword::defaults()],
]);
如何自定义错误消息?
$rules = [
'password' => ['required', 'confirmed', RulesPassword::defaults()]
];
$customMessages = [
'password.confirmed' => 'The :attribute does not match' // change it at here
];
$this->validate($request, $rules, $customMessages);
规则confirmed
正在验证的字段必须具有匹配项CCD_ 7字段。例如如果验证中的字段是password
,在输入中必须存在匹配的CCD_ 9字段。