Skip to content

Commit

Permalink
feat(isMobilePhone): add El Salvador es-SV locale
Browse files Browse the repository at this point in the history
* Solve issue with wrong validation on El Salvador mobile phones
* update tests accordingly

in order to define the right regEx, the following site was
consulted.

https://www.siget.gob.sv/guia-de-servicios/consulta-el-plan-de-numeracion/numeros-moviles/
  • Loading branch information
hereje authored and profnandaa committed Oct 31, 2021
1 parent 29017ec commit 3f1eb3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const phones = {
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
'es-PA': /^(\+?507)\d{7,8}$/,
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
'es-SV': /^(\+?503)?[67]\d{7}$/,
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
'es-VE': /^(\+?58)?(2|4)\d{9}$/,
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,
Expand Down
24 changes: 24 additions & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7459,6 +7459,30 @@ describe('Validators', () => {
'+591993546843',
],
},
{
locale: 'es-SV',
valid: [
'62136634',
'50361366631',
'+50361366634',
'+50361367217',
'+50361367460',
'+50371367632',
'+50371367767',
'+50371368314',
],
invalid: [
'+5032136663',
'21346663',
'+50321366663',
'12345',
'El salvador',
'this should fail',
'+5032222',
'+503 1111 1111',
'00 +503 1234 5678',
],
},
{
locale: 'es-UY',
valid: [
Expand Down

0 comments on commit 3f1eb3d

Please sign in to comment.