PIIGuard / Detectors

Phone Number

Detects US phone numbers using NANP (North American Numbering Plan) validation. Area code and exchange must both start with 2–9. Fictional numbers (555-0100 through 555-0199, used in film/TV) are detected but flagged.

Endpoint: POST /v1/pii/detect/phone

Validation & Confidence

NANP rules — area code 200–999, exchange 200–999. 555-01xx range flagged as fictional.

Always 1.0 for structurally valid NANP numbers. Severity: medium.

Example

from instructeer.guards import PIIGuard

# api_key = os.environ["INSTRUCTEER_API_KEY"]
pii = PIIGuard(api_key="rg_your_key")
result = pii.detect_phone("Call me at (415) 555-2671 or 800-867-5309")
// Response
{
  "entity_type": "US_PHONE_NUMBER",
  "value": "(415) 555-2671",
  "severity": "medium",
  "confidence": 1.0,
  "extra": { "normalized": "4155552671", "fictional": false }
}

Notes

  • Formats detected: (415) 555-2671 · 415-555-2671 · 415.555.2671 · +14155552671 · 4155552671
  • Fictional flag: Numbers in the 555-01xx range are returned with extra.fictional: true. Useful if you want to filter test data.
  • Non-US numbers: Only NANP (US, Canada, and territories) numbers are detected. International formats outside NANP are out of scope.