如何自定义"The password confirmation does not match."错误消息?



根据文档,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字段。

最新更新