Reputation: 23
I get stuck on laravel. My goal is to create a validation rule to forbid values between 5000 and 7000.
I've tested a lot of things like not_in:range(8000,9000)
but I didn't make it. Anyone have any ideas?
Thank you in advance.
Upvotes: 1
Views: 695
Reputation: 2415
You have to create a custom validation rule as mentioned in the official docs
Validator::extend('no_in_range', function($attribute, $value, $parameters)
{
return (($value < 5000) && ($value > 7000)) ? true : false;
});
I have not tested this code but this is what you are looking for. Please make adjustments as per your need.
Then you can just use no_in_range
as other validation methods.
'field' => 'no_in_range'
Upvotes: 1