My form is like this:-
There are fields which are arrays- like institute[]
, degree[]
, etc.
I am using Laravel form validation, but I can't get to have the customized validation messages. Here is my code:-
$validationCondition = array(
"institute" => "required|array|min:1",
"institute.*" => "required|string|distinct|min:3",
"degree" => "required|array|min:1",
"degree.*" => "required|string|distinct|min:3",
); // validation condition
$validationMessages = array(
'institute.required' => 'Please provide at least one institute record',
'institute.min' => 'Please provide at least one institute record',
'institute.*.string' => 'Institute name should be string',
'institute.*.distinct' => 'Institute name should be distinct',
'institute.*.min' => 'Institute name should be three characters at least',
'degree.required' => 'Please provide at least one institute record',
'degree.min' => 'Please provide at least one degree record',
'degree.*.string' => 'Degree name should be string',
'degree.*.distinct' => 'Degree name should be distinct',
'degree.*.min' => 'Degree name should be three characters at least',
); // validation message
$Validator = Validator::make($request->all(), $validationCondition, $validationMessages);
However, when I am submitting only one set of form input with either of the institute and degree blank, I am getting message in this way
The institute.0 field is required.
The degree.0 field is required.
I want, it should display "Please provide the degree data for record 1" when record 1 (index 0) is missing.
How can I do that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire