after_or_equal validation does not work in laravel 5.2

Viewed 3862

I want to compare start_date with end_date , and end_date should be equal or greater then start_date, i am using after_or_equal validation.

return Validator::make($data, [
      'start_date' => 'required',
      'end_date' => 'required|date_format:Y-m-d|after_or_equal:start_date'
]);


after_or_create validation of laravel5.2 return error like this.
Method [validateAfterOrEqual] does not exist.
3 Answers

Simply send your date back by 1 day and use the after: rule!

$yesterday = date('Y-m-d', strtotime('-1 days');

$rule = ['start_date' => 'required|after:'.$yesterday];

This will work for all versions of laravel as long as the after: or before: rules are there.

Related