Showing posts with label validation date format laravel. Show all posts
Showing posts with label validation date format laravel. Show all posts

Laravel date_format Validation Example

Laravel date_format Validation Example
Hi Guys,

In this tutorial I will show laravel Date Format Validation example 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
/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
public function store(Request $request)
{
    $request->validate([
        'start_date' => 'date_format:d/m/Y',
        'end_date' => 'date_format:d/m/Y'
    ]);
}
OR
/**
 * Show the application dashboard.
 *
 * @return \Illuminate\Contracts\Support\Renderable
 */
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 ...