php - Validation range in laravel

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 likenot_in:range(8000,9000)
but I didn't make it. Anyone have any ideas?
Thank you in advance.
Answer
Solution:
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 useno_in_range
as other validation methods.
'field' => 'no_in_range'
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: too few arguments to function laravel
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.