From 7bcd2f030edd9ce599acc964d956185a0ddc4dc9 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Fri, 2 Dec 2022 22:33:32 +0100 Subject: [PATCH 1/2] fix(isMobilePhone): fix invalid RegExp for dv-MV The RegExp and corresponding tests were testing a wrong format. Correct format can be found in the numbering plan: https://web.archive.org/web/20220614004138/https://cam.gov.mv/docs/Numbering_plan.pdf fixes issue #2101 --- src/lib/isMobilePhone.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index a5424ff34..a48fdce3c 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -30,7 +30,7 @@ const phones = { 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, 'de-CH': /^(\+41|0)([1-9])\d{1,9}$/, 'de-LU': /^(\+352)?((6\d1)\d{6})$/, - 'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/, + 'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/, 'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/, 'el-CY': /^(\+?357?)?(9(9|6)\d{6})$/, 'en-AI': /^(\+?1|0)264(?:2(35|92)|4(?:6[1-2]|76|97)|5(?:3[6-9]|8[1-4])|7(?:2(4|9)|72))\d{4}$/, From fba5b32278c3feb0ebacb65499ef4cf58ab418ee Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Fri, 2 Dec 2022 22:36:29 +0100 Subject: [PATCH 2/2] test(isMobilePhone): fix tests for dv-MV RegExp associated with issue #2101 --- test/validators.test.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/test/validators.test.js b/test/validators.test.js index 0405a7d2f..9d9808364 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -9495,18 +9495,30 @@ describe('Validators', () => { { locale: 'dv-MV', valid: [ - '+960973256874', - '781246378', - '+960766354789', - '+960912354789', + '+9609112345', + '+9609958973', + '+9607258963', + '+9607958463', + '9609112345', + '9609958973', + '9607212963', + '9607986963', + '9112345', + '9958973', + '7258963', + '7958963', ], invalid: [ '+96059234567', '+96045789', '7812463784', - '+960706985478', - '+960926985478', 'NotANumber', + '+9607112345', + '+9609012345', + '+609012345', + '+96071123456', + '3412345', + '9603412345', ], }, {