There is a very easy way exists in Laravel to validate date. But sometimes we need to extend our validation rule for date validation. May you do not know how to validate the date format in Laravel.

In this tutorial, I will show you start date and end date validation in laravel 10 application with laravel validation date format. I will also show you also laravel validation date after or equal today or even more how to use laravel validation after date for validating date in Larave.

Let's see the common date validation example:

App\Http\Requests\CreateMeetingRequest.php

<?php

namespace App\Http\Requests;

use Carbon\Carbon;
use Illuminate\Validation\Rules\File;
use Illuminate\Foundation\Http\FormRequest;

class CreateMeetingRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'meeting_date'     => 'required|date'
        ];
    }
}

 

Now assume, the meeting date should be after today. How we can validate that? See the example:

<?php

namespace App\Http\Requests;

use Carbon\Carbon;
use Illuminate\Validation\Rules\File;
use Illuminate\Foundation\Http\FormRequest;

class CreateMeetingRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'meeting_date'     => 'required|date|after:today',
        ];
    }
}

 

Read also: Required If Other Field Is Null Laravel Validation Example

 

Conclusion

Now we know start date and end date validation in laravel 10. Now we know laravel validation date after or equal today. Hope this laravel validation after date tutorial will help you.