Skip to content

Commit 6c1a29a

Browse files
committed
fix: (isMobilePhone) add El Salvador validation
* 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/
1 parent a1a6677 commit 6c1a29a

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/lib/isMobilePhone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const phones = {
6767
'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/,
6868
'es-PA': /^(\+?507)\d{7,8}$/,
6969
'es-PY': /^(\+?595|0)9[9876]\d{7}$/,
70-
'es-SV': /^(\+?503)?\d{7,8}$/,
70+
'es-SV': /^(\+?503)?[67]\d{7}$/,
7171
'es-UY': /^(\+598|0)9[1-9][\d]{6}$/,
7272
'es-VE': /^(\+?58)?(2|4)\d{9}$/,
7373
'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/,

test/validators.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7164,15 +7164,19 @@ describe('Validators', () => {
71647164
{
71657165
locale: 'es-SV',
71667166
valid: [
7167-
'+5032136663',
7168-
'+50321366634',
7169-
'+50321367217',
7170-
'+50321367460',
7171-
'+50321367632',
7172-
'+50321367767',
7173-
'+50321368314',
7167+
'62136634',
7168+
'50361366631',
7169+
'+50361366634',
7170+
'+50361367217',
7171+
'+50361367460',
7172+
'+50371367632',
7173+
'+50371367767',
7174+
'+50371368314',
71747175
],
71757176
invalid: [
7177+
'+5032136663',
7178+
'21346663',
7179+
'+50321366663',
71767180
'12345',
71777181
'El salvador',
71787182
'this should fail',

0 commit comments

Comments
 (0)