From 7a56ecddba734b5dd1d2f1f45f493e6d3a464a08 Mon Sep 17 00:00:00 2001 From: shrawak Date: Tue, 31 Mar 2026 20:04:14 +0545 Subject: [PATCH 1/3] fix(isMobilePhone): fix es-PA regex to validate only Panamanian mobile numbers The previous regex /^(\+?507)\d{7,8}$/ was too permissive: - Allowed any starting digit after country code (should be 6 for mobile) - Accepted 7 or 8 digit lengths (mobile must be exactly 8 digits) - Did not support hyphenated format (6XXX-XXXX) The new regex /^(\+?507)6\d{3}-?\d{4}$/ enforces: - Mobile numbers must start with 6 - Exactly 8 digits after country code - Optional hyphen in 6XXX-XXXX format References: - https://en.wikipedia.org/wiki/Telephone_numbers_in_Panama - Panamanian mobile numbers: +507 6XXX-XXXX Fixes #2433 --- src/lib/isMobilePhone.js | 2 +- test/validators.test.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 84b8fcce0..4f3c39c2d 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -88,7 +88,7 @@ const phones = { 'es-PE': /^(\+?51)?9\d{8}$/, 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/, 'es-NI': /^(\+?505)\d{7,8}$/, - 'es-PA': /^(\+?507)\d{7,8}$/, + 'es-PA': /^(\+?507)6\d{3}-?\d{4}$/, 'es-PY': /^(\+?595|0)9[9876]\d{7}$/, 'es-SV': /^(\+?503)?[67]\d{7}$/, 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/, diff --git a/test/validators.test.js b/test/validators.test.js index 1fa629092..4b73d8353 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -9588,10 +9588,11 @@ describe('Validators', () => { { locale: 'es-PA', valid: [ - '+5076784565', - '+5074321557', - '5073331112', - '+50723431212', + '+50761234567', + '+50768456789', + '50762345678', + '+5076123-4567', + '+50769876543', ], invalid: [ '+50755555', @@ -9599,6 +9600,10 @@ describe('Validators', () => { '2001236542', '+507987643254', '+507jjjghtf', + '+50712345678', + '+5073456789', + '+507234312', + '+50751234567', ], }, { From a032ad137bc291f02ad32a80e7f329a336d83879 Mon Sep 17 00:00:00 2001 From: shrawak Date: Tue, 31 Mar 2026 23:13:29 +0545 Subject: [PATCH 2/3] fix(isMobilePhone): update es-PA regex to allow spaces in mobile number format --- src/lib/isMobilePhone.js | 2 +- test/validators.test.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/isMobilePhone.js b/src/lib/isMobilePhone.js index 4f3c39c2d..8cf86383d 100644 --- a/src/lib/isMobilePhone.js +++ b/src/lib/isMobilePhone.js @@ -88,7 +88,7 @@ const phones = { 'es-PE': /^(\+?51)?9\d{8}$/, 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/, 'es-NI': /^(\+?505)\d{7,8}$/, - 'es-PA': /^(\+?507)6\d{3}-?\d{4}$/, + 'es-PA': /^(\+?507)[-\s]?6\d{3}-?\d{4}$/, 'es-PY': /^(\+?595|0)9[9876]\d{7}$/, 'es-SV': /^(\+?503)?[67]\d{7}$/, 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/, diff --git a/test/validators.test.js b/test/validators.test.js index 4b73d8353..78f42bfee 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -9592,6 +9592,7 @@ describe('Validators', () => { '+50768456789', '50762345678', '+5076123-4567', + '+507 6123-4567', '+50769876543', ], invalid: [ From 0419be0fbea762e6087fdabd954cfa5f62296000 Mon Sep 17 00:00:00 2001 From: shrawak Date: Tue, 31 Mar 2026 23:19:21 +0545 Subject: [PATCH 3/3] fix(isMobilePhone): add additional invalid mobile number format for es-PA --- test/validators.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/validators.test.js b/test/validators.test.js index 78f42bfee..1446078d1 100644 --- a/test/validators.test.js +++ b/test/validators.test.js @@ -9605,6 +9605,7 @@ describe('Validators', () => { '+5073456789', '+507234312', '+50751234567', + '+5076123456', ], }, {