0
votes

I have a set of validation rules in laravel. there are two date fields that one of them have to be greater than other. but when I use gt operator, an error apears:

$validation =  Validator::make($request->all(), [
   'description'   => 'required|string',
   'started_at'    => 'required|date',
   'finished_at'   => 'required|date|gt:started_at',
]);

error is: Method Illuminate\Validation\Validator::validateGt does not exist.

1
last version. 5.6 @prd - reza
'required|date|gt:started_at', 'gt:started_at' is wrong, gt rule does not exist in laravel, you can use 'required|date|after:started_at', - Davit

1 Answers

3
votes

gt:started_at is wrong gt rule does not exist in laravel use after

$validation =  Validator::make($request->all(), [
   'description'   => 'required|string',
   'started_at'    => 'required|date',
   'finished_at'   => 'required|date|after:started_at',
]);