vendredi 26 février 2021

how to make validation rule for a field if another field is not empty in laravel

I have two input field one is startDate input field and another is endDate input field.I want to make validation rule such that if startDate field is not empty than endDate should not be empty and vice versa.So How to make validation rule for that.Below is the validation I have put on it

'startDate' => [ 'nullable', 'date_format:d-m-Y' ],
'endDate'   => [ 'nullable', 'date_format:d-m-Y', 'after_or_equal:startDate' ]


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire