Does digit_between:min, max in Laravel 5.7 accept symbols which are allowed in numeric type?

281 Views Asked by At

I have been working on Laravel for a while and trying to write a validation for a form, specifically for a phone number.

For validating the phone number field, I using the digits_between:min, max validation rule

When I input a phone number without any symbols like + or - it works just fine, for eg: 918569633256 works fine and passes the digits_between validation for which min is 10 and max is 20.

But when I input something like '+918569633656', it fails the validation of digits_between . Can someone help me knowing if digits_between accepts special symbols like + or should I go with regex if I want symbols?

1

There are 1 best solutions below

0
On BEST ANSWER

Here you can find the regex behind digit_between validation and as you can see it only accepts numbers without symbols https://github.com/laravel/framework/blob/5.7/src/Illuminate/Validation/Concerns/ValidatesAttributes.php#L471