From e3bd52db2eb7f46352e3b839ff621a7b70f0f990 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Mon, 23 Jan 2023 22:26:53 +0100 Subject: [PATCH] fix(isMobilePhone): fix 'ms-MY' regexp 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 --- src/lib/isMobilePhone.js | 2 +- test/validators.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index a5424ff34..b58f76af1 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -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}$/, diff --git a/test/validators.js b/test/validators.js index 521549585..8b54a23d1 100644 --- a/test/validators.js +++ b/test/validators.js @@ -8643,6 +8643,8 @@ describe('Validators', () => { '088-261987', '1800-88-8687', '088-320000', + '+01112353576', + '+0111419752', ], }, {