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

Prevent isMobilePhone from allowing landline numbers in es-CO #1623

Merged
merged 2 commits into from
Mar 12, 2021

Conversation

tux-tn
Copy link
Member

@tux-tn tux-tn commented Mar 4, 2021

Fixes #1622
The regex for es-Co mobile phone validation updated in #1541 is allowing landline numbers. The solo purpose of this PR is to allow only mobile phone numbers to be validated

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)

@codecov
Copy link

codecov bot commented Mar 4, 2021

Codecov Report

Merging #1623 (da90b9e) into master (deb1d1e) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1623   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          100       100           
  Lines         1807      1807           
=========================================
  Hits          1807      1807           
Impacted Files Coverage Δ
src/lib/isMobilePhone.js 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update deb1d1e...9ab2f2b. Read the comment docs.

jhoalx
jhoalx previously approved these changes Mar 4, 2021
Copy link

@jhoalx jhoalx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solves main problem completely (no landlines),

though still passing some inexisting carriers/operators (353 ... 359),
below is an ugly, but efficient regex i modified based on yours,

/^(\+?57)?(300|301|302|304|305|310|311|312|313|314|315|316|317|318|319|320|321|322|323|324|350|351)\d{7}$/

notice i removed the '03' from the first capture group as it's only the way people dials from a landline to mobile (works in colombia only, not really part of the mobile number,
+57 country code is ok though, as it works worldwide)

i approve it since the main issue is solved,

yet if we want to be strict and not allow inexisting operators, that's my ugly proposal as i'm not that good with regex (dont know if it has some kind of conditionals)

Thank you very much.

@tux-tn
Copy link
Member Author

tux-tn commented Mar 5, 2021

@jhoalx Thank you for the explanation and the feedback, i changed the regex to reflect the edge cases you mentioned

@profnandaa profnandaa merged commit 418df05 into validatorjs:master Mar 12, 2021
@tux-tn tux-tn deleted the hotfix/isMobilePhone branch March 12, 2021 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(isMobilePhone): es-CO locale, passing landlines as valid
3 participants