Skip to content

Commit

Permalink
fix(isMobilePhone): fix 'ms-MY' regexp
Browse files Browse the repository at this point in the history
refactored the regexp:
---
* removed meaningless {1} quantifiers
* simplified regexp a bit (removing useless escape character)
* fixed the bug that would cause it to match invalid numbers

tests
---
* added tests for invalid numbers

fixes #1066
  • Loading branch information
pano9000 committed Jan 28, 2023
1 parent f97e8d4 commit a260c5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const phones = {
'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
'my-MM': /^(\+?959|09|9)(2[5-7]|3[1-2]|4[0-5]|6[6-9]|7[5-9]|9[6-9])[0-9]{7}$/,
'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
'nb-NO': /^(\+?47)?[49]\d{7}$/,
'ne-NP': /^(\+?977)?9[78]\d{8}$/,
Expand Down
2 changes: 2 additions & 0 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8593,6 +8593,8 @@ describe('Validators', () => {
'088-261987',
'1800-88-8687',
'088-320000',
'+01112353576',
'+0111419752',
],
},
{
Expand Down

0 comments on commit a260c5f

Please sign in to comment.