Reputation: 1009
I am using laravel to allow users to create ranges. So they have to enter a start and end value for the range.I want to validate that the start is always less than the end and that the end is always larger that the start so I added this to the validation rules:
'start' => 'max:'. $this->get('end),
'end' => 'min:'.$this->get('start)
I have just tested with start as 20 and end as 2000 and it gives an error saying that the start must be less than the end value!! Just to be clear I am using laravel form helper with a number type input.
Upvotes: 1
Views: 185
Reputation: 1009
I added the numeric constraint and it worked. I think before that it was evaluating the value as string so when start=20 and end=2000 that violated the rule because end didnt have a min length of 20.
'start' => 'numeric|max:'.$request->get('end'),
'end' => 'numeric|min:'.$request->get('start'),
Upvotes: 1