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

Incorrect Indian Mobile number matches with wrong locale and returns true #1740

Closed
ankitAtVauld opened this issue Oct 1, 2021 · 3 comments
Closed
Labels

Comments

@ankitAtVauld
Copy link

Describe the bug
While testing the lib for Indian mobile numbers, passing incorrect mobile number without options, matches with Bangladesh regex and returns true.

Examples
mobile = "+91895713829";
isMobilePhone(mobile); // returns true

Additional context
Validator.js version: "^10.11.0"
Node.js version: 14
OS platform: macOS

@akkaraju-satvik
Copy link

akkaraju-satvik commented Oct 2, 2021

Hey @ankitAtVauld, i tried reproducing the bug with the example you have provided. It seems that you are providing just the mobile phone number, please try adding the locale parameter, i.e., 'en-IN' for India, to the isMobilePhone function

With Locale
image

Without Locale
image

@tux-tn
Copy link
Member

tux-tn commented Oct 2, 2021

@akkaraju-satvik Actually using isMobilePhone without a locale is a correct behaviour and will test the phone number with all available locales.
The faulty regex has been changed in #1032 and added to [email protected], @ankitduseja please update to a more recent version of the package to fix your issue.

@akkaraju-satvik
Copy link

@akkaraju-satvik Actually using isMobilePhone without a locale is a correct behaviour and will test the phone number with all available locales. The faulty regex has been changed in #1032 and added to [email protected], @ankitduseja please update to a more recent version of the package to fix your issue.

Thank you for the insight @tux-tn :)

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

No branches or pull requests

4 participants