我有此验证规则,我想在其中显示一些自定义消息而不是自定义消息。但是像下面这样不起作用,验证消息如下所示:
The participant.1.name field is required.
The participant.1.surname field is required.
但它应显示为:
The field name is required
The field surname is required
验证规则:
$this->validate($request,
[
'participant.*.name' => 'required|string',
'participant.*.surname' => 'required|string',
],
[
'participant.*.name' => 'The field name is required.',
'participant.*.name' => 'Please insert a text value for the name field.',
'participant.*.surname' => 'The field surname is required',
'participant.*.surname' => 'Please insert a text value for the surname field'
]
);
答案 0 :(得分:1)
您可以自定义验证消息,有关更多详细信息,
https://laravel.com/docs/5.6/validation#customizing-the-error-messages
另外,请尝试这个
$messages = [
'participant.1.name.required' => 'The Participant name is required.',
];
$validator = Validator::make($input, $rules, $messages);