Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IsMobilePhone.js - Update Regular Expression for Validating Panamanian Phone Numbers #2433

Open
Nauj-Montes opened this issue Jul 25, 2024 · 6 comments
Labels

Comments

@Nauj-Montes
Copy link

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

  1. 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).
  2. 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.

Description

  1. 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:

Description

Action Required

  • Update the existing regular expression to the recommended solution to ensure accurate validation of Panamanian phone numbers.
@VanshajTiwari
Copy link

Please assign this issue to me

@Nauj-Montes
Copy link
Author

Please assign this issue to me

@VanshajTiwari I don't have the necessary permissions to assign issues.

@pano9000
Copy link
Contributor

pano9000 commented Sep 4, 2024

the validator is called isMobilePhone.js, so it should in theory only validate mobile phones not landline numbers :-)

So me personally, would regard this as a non-issue.

if we need support for landline numbers, maybe there should be a new validator called isTelephoneNumber, which maybe has an option to validate mobile, landline or BOTH.

but that is worth another issue

@ShreySinha02
Copy link

@Nauj-Montes @pano9000 is this issue valid if yes can i work on it

@Nauj-Montes
Copy link
Author

Nauj-Montes commented Sep 9, 2024

@pano9000 @ShreySinha02 I understand landline numbers should't be verified, even taking out landline numbers validation, the existent validation on isMobilePhone.js is still is insufficient for Panamanian phone numbers, I will proceed making an update to the issue, thank you for the observation.

@PVSTEJA24
Copy link

@Nauj-Montes @pano9000 Hey, Can I work on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants