例如,我对HTML表单进行了验证:
$validator = Validator::make($request->all(), [
"code" => "required|string|size:10"]);
如果我收到错误,请看:
The code field is required.
Wrere code
是字段名称。
我如何翻译(本地化)这个?
答案 0 :(得分:4)
您可以在make方法中传递第三个参数:
$rules = [
"code" => "required|string|size:10",
];
$messages = [
'required' => 'The :attribute field is required.',
];
$validator = Validator::make($input, $rules, $messages);
跳这个有帮助!