Skip to content
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 accept invalid phone numbers #2055

Closed
ValeriyaZavozova opened this issue Oct 3, 2022 · 11 comments · Fixed by #2156
Closed

isMobilePhone accept invalid phone numbers #2055

ValeriyaZavozova opened this issue Oct 3, 2022 · 11 comments · Fixed by #2156
Assignees

Comments

@ValeriyaZavozova
Copy link

ValeriyaZavozova commented Oct 3, 2022

Describe the bug
A clear and concise description of what the bug is.

isMobilePhone successfully validates invalid numbers (see examples below).
I suppose the problem is in the next regular expressions:
'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/,
'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,

Examples
If applicable, add screenshots to help explain your problem.

The next numbers will be accepted as valid even though the are not:
+0711419752
+0765351689
+0111419752

Additional context
Validator.js version: 13.7.0
Node.js version: v18.9.1
OS platform: [windows, linux, macOS, etc] macOS

@meeraj257
Copy link

@ValeriyaZavozova - the above bug is for ro-RO locale (i.e Romania) and ms-MY locale (i.e Malaysia)?

@shikhar13012001
Copy link

Hi @ValeriyaZavozova I am interested in this issue, Can you please assign this to me ?
Thanks.

@ValeriyaZavozova
Copy link
Author

@meeraj257 I found only this two cases

@VarnikaB
Copy link

VarnikaB commented Oct 6, 2022

Could anyone verify if - 01468987837 is valid
and are these 088387675, 16-2838768 invalid? for ms-my

@nick-cd
Copy link

nick-cd commented Oct 6, 2022

@VarnikaB I researched a little on Malaysian telephony on the relevant Wikipedia page. From what I gathered from my research, here's what I can conclude about those numbers.

088387675 is an east Malaysian landline number; it is not a mobile phone number. In the area code, the first digit, ignoring the leading zero, is eight, but it must be one. (Also, if we wanted to convert this into a mobile number, the successor number needs one more digit, but that's not the main point I want to emphasize here.)

01468987837 is invalid. This number has an extra digit in the sequence of digits after the area code (014). There should only be seven digits (in this case) after the area code, not eight.

16-2838768 is an invalid number. It does not start with the number zero.

@VarnikaB
Copy link

ok

@609harsh
Copy link

hi Please assign it to me. I am interested in this

@braaar
Copy link
Contributor

braaar commented Oct 20, 2022

hi Please assign it to me. I am interested in this

The maintainers in this repo don't typically assign issues to contributors. Feel free to make a PR, of course!

@pano9000
Copy link
Contributor

FWIW: I can confirm that the numbers return "true" with isMobilePhone:

+0711419752
+0765351689
+0111419752

that last one is similarly also reported here: #1066

both are caused by the regexp optionally matching the country code and allowing numbers to also start with 0
I'll take a stab at fixing these in the current version this evening.

For a more future proof solution, there also is a discussion going on here #2124

@pano9000
Copy link
Contributor

that +0111419752 will be fixed with PR #2155

will now also take a look at those issues caused by the Romanian Regexp

pano9000 added a commit to pano9000/validator.js that referenced this issue Jan 23, 2023
* fixed the bug that would cause it to match invalid numbers
* added tests for invalid numbers

fixes validatorjs#2055
@pano9000
Copy link
Contributor

+0711419752
+0765351689

those types of numbers will be fixed by #2156

pano9000 added a commit to pano9000/validator.js that referenced this issue Jan 28, 2023
* fixed the bug that would cause it to match invalid numbers
* added tests for invalid numbers

fixes validatorjs#2055
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants