Skip to content

Commit 3f1eb3d

Browse files
herejeprofnandaa
authored andcommitted
feat(isMobilePhone): add El Salvador es-SV locale
* 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 29017ec commit 3f1eb3d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/lib/isMobilePhone.js

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

test/validators.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7459,6 +7459,30 @@ describe('Validators', () => {
74597459
'+591993546843',
74607460
],
74617461
},
7462+
{
7463+
locale: 'es-SV',
7464+
valid: [
7465+
'62136634',
7466+
'50361366631',
7467+
'+50361366634',
7468+
'+50361367217',
7469+
'+50361367460',
7470+
'+50371367632',
7471+
'+50371367767',
7472+
'+50371368314',
7473+
],
7474+
invalid: [
7475+
'+5032136663',
7476+
'21346663',
7477+
'+50321366663',
7478+
'12345',
7479+
'El salvador',
7480+
'this should fail',
7481+
'+5032222',
7482+
'+503 1111 1111',
7483+
'00 +503 1234 5678',
7484+
],
7485+
},
74627486
{
74637487
locale: 'es-UY',
74647488
valid: [

0 commit comments

Comments
 (0)