Laravel 7 provides a rich set of date validation rules.
The field under validation must be a valid date according to the strtotime
PHP function
The field under validation must be equal to the given date. The dates will be passed into the PHP strtotime
function.
The field under validation must match the given format. You should use either date
or date_format
when validating a field, not both.This validation rule supports all formats supported by PHP's DateTime
class.
start_date' => ['date_format:m/d/Y']
The field under validation must be a value after a given date. The dates will be passed into the strtotime
PHP function
'start_date' => 'required|date|after:tomorrow'
Instead of passing a date string to be evaluated by strtotime
, you may specify another field to compare against the date:
'finish_date' => 'required|date|after:start_date'
The field under validation must be a value after or equal to the given date. For more information, see the after rule.
The field under validation must be a value preceding the given date. The dates will be passed into the PHP strtotime
function.
The field under validation must be a value preceding or equal to the given date. The dates will be passed into the PHP strtotime
function.