Skip to content

Commit d25559b

Browse files
authored
fix(isMobilePhone): fix wrong dv-MV mobile phone matching (issue #2101) (#2109)
* 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 * test(isMobilePhone): fix tests for dv-MV RegExp associated with issue #2101
1 parent f97e8d4 commit d25559b

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const phones = {
3030
'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/,
3131
'de-CH': /^(\+41|0)([1-9])\d{1,9}$/,
3232
'de-LU': /^(\+352)?((6\d1)\d{6})$/,
33-
'dv-MV': /^(\+?960)?(7[2-9]|91|9[3-9])\d{7}$/,
33+
'dv-MV': /^(\+?960)?(7[2-9]|9[1-9])\d{5}$/,
3434
'el-GR': /^(\+?30|0)?6(8[5-9]|9(?![26])[0-9])\d{7}$/,
3535
'el-CY': /^(\+?357?)?(9(9|6)\d{6})$/,
3636
'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}$/,

test/validators.test.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9495,18 +9495,30 @@ describe('Validators', () => {
94959495
{
94969496
locale: 'dv-MV',
94979497
valid: [
9498-
'+960973256874',
9499-
'781246378',
9500-
'+960766354789',
9501-
'+960912354789',
9498+
'+9609112345',
9499+
'+9609958973',
9500+
'+9607258963',
9501+
'+9607958463',
9502+
'9609112345',
9503+
'9609958973',
9504+
'9607212963',
9505+
'9607986963',
9506+
'9112345',
9507+
'9958973',
9508+
'7258963',
9509+
'7958963',
95029510
],
95039511
invalid: [
95049512
'+96059234567',
95059513
'+96045789',
95069514
'7812463784',
9507-
'+960706985478',
9508-
'+960926985478',
95099515
'NotANumber',
9516+
'+9607112345',
9517+
'+9609012345',
9518+
'+609012345',
9519+
'+96071123456',
9520+
'3412345',
9521+
'9603412345',
95109522
],
95119523
},
95129524
{

0 commit comments

Comments
 (0)