FastPII Docs
Detectors

Phone Number

Detect Czech mobile and landline numbers with context gating and operator or area metadata.

Purpose

Use the phone detector for Czech phone numbers.

This detector reports accuracy above 95% and distinguishes mobile from landline numbers.

It is intentionally conservative for local numbers without +420, because it requires nearby phone-related context before accepting them.

Detector Name

phone

Supported Formats

  • Mobile: +420 60x xxx xxx
  • Mobile: +420 7xx xxx xxx
  • Landline: +420 2xxxxxxxx through +420 5xxxxxxxx
  • Local forms without +420 can also match when context is present

Examples:

  • +420 602 123 456
  • Mobile: 777 123 456
  • Office: +420 2 1234 5678

Validation Logic

This detector uses both pattern checks and context checks.

Detection Rules

  1. Match either the mobile or landline pattern.
  2. Reject matches embedded inside larger digit sequences.
  3. Reject matches that sit inside a bank-account pattern.
  4. If the raw match starts with +420, accept it directly.
  5. If it does not start with +420, require a phone-related keyword within 50 characters before the number.

Validation Rules

  • FastPII normalizes spaces, dashes, and a leading +.
  • If the value starts with 420, that prefix is stripped for validation.
  • Mobile values must be 9 digits and start with 6 or 7.
  • Landline values must be 9 digits and start with 2, 3, 4, or 5.

There is no checksum algorithm for this detector.

Python Examples

Detect a mobile number

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])
result = guard.detect("Mobile: +420 602 123 456", detector_names=["phone"])

for finding in result.findings:
    print(finding.value, finding.metadata)

Validate a number directly

from fastpii import PrivacyGuard

guard = PrivacyGuard(regions=["cz"])
result = guard.validate("+420 602 123 456", "phone")

print(result.is_valid)
print(result.metadata)

Expected Metadata

This detector returns:

  • phone_type: mobile or landline
  • operator: for mobile numbers, such as O2, T-Mobile, or Vodafone
  • area: for landline numbers, such as Praha

Example Output

{
    "phone_type": "mobile",
    "operator": "O2",
}

Limitations

  • Local numbers without +420 are ignored unless context appears before the match.
  • Operator mapping is prefix-based and may return other.
  • Landline metadata uses broad regional groupings, not exact subscriber location.

Notes

Verified detection example from the codebase:

guard.detect("Mobile: +420 602 123 456")

On this page