Skip to content

Commit

Permalink
fix: (isMobilePhone) add El Salvador validation
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 committed Oct 10, 2021
1 parent a1a6677 commit 6c1a29a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/isMobilePhone.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,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)?\d{7,8}$/,
'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
18 changes: 11 additions & 7 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7164,15 +7164,19 @@ describe('Validators', () => {
{
locale: 'es-SV',
valid: [
'+5032136663',
'+50321366634',
'+50321367217',
'+50321367460',
'+50321367632',
'+50321367767',
'+50321368314',
'62136634',
'50361366631',
'+50361366634',
'+50361367217',
'+50361367460',
'+50371367632',
'+50371367767',
'+50371368314',
],
invalid: [
'+5032136663',
'21346663',
'+50321366663',
'12345',
'El salvador',
'this should fail',
Expand Down

0 comments on commit 6c1a29a

Please sign in to comment.