Skip to content

[FEATURE] Create Phone Number Validator #27

@rubemfsv

Description

@rubemfsv

Description

Validates phone numbers to ensure they adhere to a specific format or pattern.

Expected Behavior
The Phone Number Validator should validate phone numbers based on the following criteria, taking into account international differences in phone number formats:

  1. International Format Support: Recognize and validate phone numbers in various international formats, accommodating differences in country codes, area codes, and local number lengths.
  2. Country-Specific Rules: Apply country-specific rules when validating phone numbers to account for variations in formatting, digit length, and prefix requirements.
  3. Digits-Only Validation: Verify that the phone number consists of valid numeric digits and optional special characters like hyphens, parentheses, or plus signs.
  4. Prefix Validation: If applicable, ensure that the phone number includes the correct country dialing code or prefix for international numbers.
  5. Minimum and Maximum Length: Enforce minimum and maximum length constraints on phone numbers, taking into account any country-specific variations.
  6. Consistent Validation: Provide consistent validation results regardless of how the user enters the phone number (with or without formatting characters).
  7. Error Messages: Offer clear and localized error messages or guidance to users when their input doesn't conform to the expected phone number format.
  8. Fallback Validation: If a phone number does not match any recognized format, allow for a fallback validation approach, such as basic digit counting, to handle non-standard cases.
  9. Optional Features: Optionally, provide features for formatting phone numbers in a standardized way, such as adding hyphens or parentheses for display purposes.
  10. Country Code Detection: Automatically detect and validate the country code when it's not explicitly provided by the user.

This behavior ensures that the Phone Number Validator accommodates the diverse range of phone number formats used internationally, offering a reliable and user-friendly way to validate phone numbers while considering country-specific variations.

Additional Information

Consider implementing this validator along with a corresponding unit test in the "validators" directory, alongside the existing validators.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions