You can create custom validation
https://laravel.com/docs/5.2/validation#custom-validation-rules
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I have a question about validation...I have a form that accepts a start date, an end date, and an option to 'use dates'. I have set up a form request and in the rules i have
'use_dates' => 'required|string|max:3',
'start_date' => 'required_if:use_dates,Yes|date_format:d/m/Y',
'end_date' => 'required_if:use_dates,Yes|date_format:d/m/Y|after:start_date',
On submit, the form always says the end date must be after the start date regardless of the option picked for use_dates. I would like it so that if use_dates is set to Yes then the start_date and end_date are both required, and that the end_date is after the start_date. If the use_dates option is anything else (the only other option is No ) then the start_date and end_date can be ignored.
Any help, or pointers in the right direction, would be greatly appreciated.
Please or to participate in this conversation.