-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
isMobilePhone for Belgian phone numbers validates also non mobile phone numbers #1684
Comments
Would you like to create a PR? |
@rubiin Yes, can make a PR if you want. |
It should only validate mobile phone numbers. |
Thanks for noting, sure, make a PR. |
@profnandaa @ezkemboi Can I raise a PR for this issue, I have verified the given regex with some random Belgian numbers I could find online. |
@divikshrivastava sure, go ahead! |
Can I raise a PR for this issue? |
@YASH3166 seems Pr has been raised |
Describe the bug
The isMobilePhone() validator should only validate mobile phone numbers.
Currently it seems that it also validates the local/regional fixed phone numbers.
Reference: https://en.wikipedia.org/wiki/Telephone_numbers_in_Belgium
Examples
Valid ones:
Invalid ones (but valid local/regional fixed phone numbers):
Examples are taking from the test cases:
valid mobile phone numbers: https://github.com/validatorjs/validator.js/blob/master/test/validators.js#L7290-L7292
valid fixed phone numbers (but no valid mobile phone numbers): https://github.com/validatorjs/validator.js/blob/master/test/validators.js#L7293-L7295
Additional context
Validator.js version: 13.6.0
Node.js version: 12.x
OS platform: windows
Possible fix (not fully tested):
Replace regex
/^(\+?32|0)4?\d{8}$/
by/^(\+?32|0)4\d{8}$/
at https://github.com/validatorjs/validator.js/blob/master/src/lib/isMobilePhone.js#L97
This should only allow:
You can even go further and also only allow the range of
04xx
numbers by provider (see wikipedia), but I think that would go too far and it also has a risk that you need to adapt your regex if a new provider (or range) is added.The text was updated successfully, but these errors were encountered: