DocsValidators

phone validator

Lightweight pattern check for phone-like strings. No country logic.

Format

Matches `/^[+]?[\d\s().-]{7,20}$/`. Optional leading `+`, then 7–20 chars of digits, spaces, parens, dots, or hyphens.

Examples

  • +41 79 123 45 67
  • (415) 555-2671
  • +1.415.555.2671

Implementation

Faithful summary of lib/validators.ts. Validators are pure functions and run identically in the worker, the Workbench, and the MCP server.

function validPhone(value) {
  // Lightweight check. Production swaps libphonenumber-js behind the same shape.
  return /^[+]?[\d\s().-]{7,20}$/.test(value)
    ? OK
    : fail('phone_invalid', 'not a valid phone')
}

Use in a template

Validators attach to a field on a custom template. The cascade runs them after mapping but before commit; failures surface in the per-row validation report.

fields:
  - column: phone
    type: phone
    validators:
      - type: phone

Common gotchas

  • No country detection. `0000000` passes — only shape and length are checked.
  • No E.164 normalisation. If you commit to FHIR, normalise first or downstream consumers see whatever the source had.
  • Total length cap is 20 characters; extensions like `x123` push some legitimate corporate numbers past the limit.
  • Opt-in `strict: true` swaps the regex for libphonenumber-js (min build). E.164 numbers that the library accepts pass; syntactically-similar invalids (e.g. `+411234`) fail. Pair with `countries: [CH, DE]` to lock to specific ISO-3166 codes — non-matching countries return `phone_country`. Default behavior is unchanged.

Related templates

  • Patient demographicspatient_demographics_v1

    Patient identity. Emits FHIR Patient.

    Fields: phone

  • Leadsleads_v1

    Sales leads: contact, source, status, and creation metadata.

    Fields: phone

  • Contactscontacts_v1

    People at named accounts: identity, contact details, role, decision-maker flag.

    Fields: phone

  • Customerscustomers_v1

    Repeat e-commerce buyers: identity, contact, default shipping, lifetime stats.

    Fields: phone

Pricing

Validators run on every committed row

Schema-only mode (headers + ≤3 sample rows) is free and unlimited; full-data commits are metered. See plans →

phone validator — AdaptivMapr