Skip to content

Commit

Permalink
fix(isMobilePhone): fix el-GR validation - add missing ranges and cor…
Browse files Browse the repository at this point in the history
…rectly exclude certain ranges (#2112)

* fix(isMobilePhone): el-GR RegExp fixed

update the RegExp to correctly match (and exclude) number ranges as per  official ITU numbering plan:
https://web.archive.org/web/20221205170159/https://www.itu.int/dms_pub/itu-t/oth/02/02/T02020000550002PDFE.pdf

fixes #2111

* tests: update tests for fixed el-GR RegExp

belongs to #2111
  • Loading branch information
pano9000 committed Jan 22, 2023
1 parent a571b3e commit 44224d7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const phones = {
'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}$/,
'el-GR': /^(\+?30|0)?(69\d{8})$/,
'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}$/,
'en-AU': /^(\+?61|0)4\d{8}$/,
Expand Down
22 changes: 21 additions & 1 deletion test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7761,8 +7761,22 @@ describe('Validators', () => {
locale: 'el-GR',
valid: [
'+306944848966',
'6944848966',
'306944848966',
'06904567890',
'6944848966',
'6904567890',
'6914567890',
'6934567890',
'6944567890',
'6954567890',
'6974567890',
'6984567890',
'6994567890',
'6854567890',
'6864567890',
'6874567890',
'6884567890',
'6894567890',
],
invalid: [
'2102323234',
Expand All @@ -7772,6 +7786,12 @@ describe('Validators', () => {
'68129485729',
'6589394827',
'298RI89572',
'6924567890',
'6964567890',
'6844567890',
'690456789',
'00690456789',
'not a number',
],
},
{
Expand Down

0 comments on commit 44224d7

Please sign in to comment.