Skip to content

[FEATURE] Extend PatternMatch Class to Implement US Postal Code and Phone Number #579

@jasonhorner

Description

@jasonhorner

Is your feature request related to a problem? Please describe.

The PatternMatch analyzer in Deequ currently lacks support for validating common US data formats, such as phone numbers and postal codes. This forces users to implement custom regex validation, leading to inconsistent implementations.

Describe the solution you'd like

Add built-in support for validating US phone numbers and postal codes using the following regex patterns:

  1. US Phone Number Regex:

    val PHONE_NUMBER_US: Regex = """^(?:\+1\s?)?(?:\(?[2-9][0-9]{2}\)?[\s-]?)?[2-9][0-9]{2}[\s-]?[0-9]{4}(?:\s?(?:ext|x|extension)\s?[0-9]{4})?$""".r
  2. US Postal Code Regex:

    val POSTAL_CODE_US: Regex = """\b\d{5}(?:-\d{4})?\b""".r

Describe alternatives you've considered

Custom regex implementations, but these add complexity and inconsistency across projects.

Additional context

These patterns are commonly used in US data validation (e.g., customer records, shipping data). Including them in Deequ would simplify validation workflows.

Additionally, the current codebase has limited unit tests and lacks examples demonstrating the use of PatternMatch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions