Laravel 6 date_format Validation Example

Laravel 6 , Laravel

Nicesnippets

3002

14-11-2019


Hi Guys,

In this tutorial laravel 6 Date Format Validation You can validate date_format validation rules. With date_format:format method you can set the preferred date format, and the filed value must match the given format.

The field under validation must match the given format. You should use either date_format when validating a field, not both. This validation rule supports all formats supported by PHP's Date class.

Example

public function store(Request $request)

{

$request->validate([

'start_date' => 'date_format:d/m/Y',

'end_date' => 'date_format:d/m/Y'

]);

}

OR

public function store(Request $request)

{

$request->validate([

'start_date' => 'date_format:Y-m-d',

'end_date' => 'date_format:Y-m-d'

]);

}

It will help you ...


Recommended Posts