Skip to content

Support the phone number filter region property for locale-aware detection #48

Description

@jzonthemtn

Summary

Support a new optional region property on the phone number filter (filterPhoneNumber.region) so a policy can set the default region(s) used to detect phone numbers written without an international + country code. This is the runtime half of PhiSQL RFC philterd/phisql#22.

region is a single ISO 3166-1 alpha-2 string or an array of them (default "US"). Numbers with a + prefix are detected regardless; the region only affects bare national-format numbers.

Requires phisql 1.2.0, the schema version that defines filterPhoneNumber.region. Blocked until this schema version is targeted.

Prerequisite

phileas-python's phone filter (phileas/filters/phone_number_filter.py) is currently a set of NANP regex patterns and does not use a phone-number library. The phonenumbers package (the Python port of libphonenumber) is not a dependency. region has no meaning until detection runs through phonenumbers, so this depends on first adopting phonenumbers and using its PhoneNumberMatcher / find API (the analog of the Java libphonenumber path). That library adoption is the prerequisite and should land first (and would also close the international-detection gap that the regex filter has today).

What to change (after adopting phonenumbers)

  1. Add phonenumbers as a dependency and detect phone numbers with it (default region "US", a leniency comparable to libphonenumber POSSIBLE).
  2. Read region from the phone filter config, accepting either a string or a list of strings (default ["US"]).
  3. Scan once per configured region and merge, de-duplicating overlapping spans. +-prefixed numbers are found regardless of region.

Backward compatibility

Additive. A policy without region behaves as the default "US".

Acceptance criteria

  • phonenumbers-based detection is in place (prerequisite).
  • The phone filter reads region as either a string or a list, defaulting to US.
  • A policy with region: "GB" detects UK national-format numbers; region: ["US","GB","FR"] detects national-format numbers from each.
  • +-prefixed international numbers are detected regardless of region.
  • Multi-region results are de-duplicated.
  • Behavior matches the Java and .NET Phileas implementations for the same policy and inputs.
  • The package targets phisql 1.2.0.

Reference: PhiSQL RFC philterd/phisql#22.

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