Skip to content

Commit f9d49fc

Browse files
authored
fix(isMobilePhone): fix 'ms-MY' regexp (#2155)
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
1 parent d61322c commit f9d49fc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const phones = {
119119
'mg-MG': /^((\+?261|0)(2|3)\d)?\d{7}$/,
120120
'mn-MN': /^(\+|00|011)?976(77|81|88|91|94|95|96|99)\d{6}$/,
121121
'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}$/,
122-
'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/,
122+
'ms-MY': /^(\+?60|0)1(([0145](-|\s)?\d{7,8})|([236-9](-|\s)?\d{7}))$/,
123123
'mz-MZ': /^(\+?258)?8[234567]\d{7}$/,
124124
'nb-NO': /^(\+?47)?[49]\d{7}$/,
125125
'ne-NP': /^(\+?977)?9[78]\d{8}$/,

test/validators.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8593,6 +8593,8 @@ describe('Validators', () => {
85938593
'088-261987',
85948594
'1800-88-8687',
85958595
'088-320000',
8596+
'+01112353576',
8597+
'+0111419752',
85968598
],
85978599
},
85988600
{

0 commit comments

Comments
 (0)