Validating a custom date format in with laravel validator

The easier option is to use the Laravel date_format:format
rule (https://laravel.com/docs/5.5/validation#rule-date-format). It’s a built-in function in Laravel without the need for a custom rule (available in Laravel 5.0+).

You can do:

$rule['date'] = 'required|date_format:d/m/Y';

or

$rule['date'] = 'required|date_format:Y-m-d';

Leave a Comment