Open
Description
Description
The current regular expression used for validating Panamanian phone numbers is flawed and needs updating to accurately match the expected formats for both landline and mobile numbers. The existing regex is as follows:
"es-PA": /^(\+?507)\d{7,8}$/
Problems with the Current Regex
-
Inaccurate Length Validation: The regex matches 7 or 8 digits after the country code, but does not account for the specific length requirements of Panamanian numbers:
- Landline Numbers: Should be exactly 7 digits long after the
507
prefix. - Mobile Numbers: Should be exactly 8 digits long after the
507
prefix, optionally formatted with a hyphen (e.g.,6XXX-XXXX
).
- Landline Numbers: Should be exactly 7 digits long after the
-
Lack of Prefix Validation: The regex does not enforce valid starting digits:
- Landline Numbers: Must start with
2
. - Mobile Numbers: Must start with
6
.
This is a problem because it allows matches such as
+50712345678
which shouldn't be valid as shown in the next screenshot. - Landline Numbers: Must start with
- Missing Hyphen Support: The current regex does not accommodate hyphens in mobile numbers, potentially causing valid numbers like
+507 6123-4567
to be incorrectly flagged as invalid as shown in the following screenshot:
Action Required
- Update the existing regular expression to the recommended solution to ensure accurate validation of Panamanian phone numbers.