From f17e220b1d8788549d5f9cb80662d001bad7fdbf Mon Sep 17 00:00:00 2001 From: Angel Mendez Date: Sat, 9 Oct 2021 15:03:28 -0500 Subject: [PATCH] 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/ --- src/lib/isMobilePhone.js | 1 + test/validators.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index f5a8ffa6b..c70310ef7 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -75,6 +75,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}$/, diff --git a/test/validators.js b/test/validators.js index 32bb79974..14e3bfc93 100644 --- a/test/validators.js +++ b/test/validators.js @@ -7576,6 +7576,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: [