Skip to content

Commit

Permalink
fix(isMobilePhone): fix wrong dv-MV mobile phone matching (issue #2101)…
Browse files Browse the repository at this point in the history
… (#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
  • Loading branch information
pano9000 authored Jan 29, 2023
1 parent f97e8d4 commit d25559b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}$/,
Expand Down
24 changes: 18 additions & 6 deletions test/validators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
],
},
{
Expand Down

0 comments on commit d25559b

Please sign in to comment.