checked this question kind of similar but not helpful in my case.
I have multiple time inputs where I need to assure that start time should not greater then end time.
My input Request dump is
array:2 [▼
"_token" => "nYb7gSp5TGTcrU9nNW9PMjJTduohLZFDLCzLGPbq"
"timings" => array:8 [▼
"day_1" => array:1 [▼
0 => "1"
]
"day_2" => array:1 [▼
0 => "1"
]
"day_3" => array:1 [▼
0 => "1"
]
"day_4" => array:1 [▼
0 => "1"
]
"day_5" => array:1 [▼
0 => "1"
]
"day_6" => array:1 [▼
0 => "1"
]
"day_7" => array:1 [▼
0 => "1"
]
"session" => array:1 [▼
0 => array:2 [▼
"start" => array:2 [▼
0 => "14:00 PM"
1 => null
]
"end" => array:2 [▼
0 => "15:00 PM"
1 => null
]
]
]
]
]
What I have did so far for this is
$rules = [
'timings.session.*.start.*' => 'nullable|date_format:H:i|before:timings.session.*.end.*',
'timings.session.*.end.*' => 'nullable|date_format:H:i|after:timings.session.*.start.*',
];
$messages = [
'timings.session.*.start.*.before' => 'Start Time should be before End Time',
'timings.session.*.end.*.after' => 'End Time should be after Start Time',
];
$validator = Validator::make($request->all(), $rules, $messages);
dd($validator->errors());
Still receiving false error message is
Illuminate\Support\MessageBag {#780 ▼
#messages: array:2 [▼
"timings.session.0.start.0" => array:2 [▼
0 => "The timings.session.0.start.0 does not match the format H:i."
1 => "Start Time should be before End Time"
]
"timings.session.0.end.0" => array:2 [▼
0 => "The timings.session.0.end.0 does not match the format H:i."
1 => "End Time should be after Start Time"
]
]
#format: ":message"
}
Questions:
a.) How to put correct validation rules for time input which insure start time should not greater then end time?
b.) How to put another validation rule for match at least one checkbox is ticked for day select?
Thanks, Hope it will help other people too.