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

fix: phone validation now only accepts 8 digit #s starting with 8 or 9 #101

Merged
merged 2 commits into from
Aug 7, 2020

Conversation

karrui
Copy link
Contributor

@karrui karrui commented Aug 6, 2020

Problem

This PR adds an even strong mobile validation (only for Singapore numbers). SG phone number validation now only accepts 8 digit numbers starting with 8 or 9 using a regex match:

nationalNumber.match(/^[89][0-9]{7}$/g)

Closes #100

Solution

Bug Fixes:

  • Increases mobile validation strength by also validating the start of the number in addition to the number length.

Before & After Screenshots

BEFORE:
Screenshot 2020-08-06 at 6 18 53 PM
Screenshot 2020-08-06 at 6 18 48 PM
Screenshot 2020-08-06 at 6 18 42 PM

AFTER:
Screenshot 2020-08-06 at 6 14 46 PM
Screenshot 2020-08-06 at 6 14 38 PM
Screenshot 2020-08-06 at 6 14 29 PM
Screenshot 2020-08-06 at 6 27 41 PM

@karrui
Copy link
Contributor Author

karrui commented Aug 6, 2020

Do not merge yet, realizes this stops home number from working. Will do the validation in the mobile phone check instead

EDIT: Fixed. Glad to see the tests worked to catch this ;)

Copy link
Contributor

@liangyuanruo liangyuanruo left a comment

Choose a reason for hiding this comment

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

lgtm

@karrui karrui merged commit a2a2b80 into develop Aug 7, 2020
@karrui karrui deleted the fix/stronger-mobile-validation branch August 7, 2020 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Mobile number validation accepts 3xxxxxx, 4xxxxxx, etc. numbers
2 participants