Docs · Validators

regex validator

Match a value against a JavaScript-flavour regular expression.

One of 19 validator types · pure compute, no AI cost

Reference

Format

Accepts any value matched by `new RegExp(pattern).test(value)`. The pattern is interpreted by V8/Node — JavaScript regex syntax, not PCRE. No flags are applied (no `i`, no `u`); embed them in the pattern with `(?i)` is NOT supported — use a character class like `[Aa]` or pre-uppercase in your transform.

Examples

  • pattern: '^[A-Z]{3}-\\d{4}$' // SKU-1234
  • pattern: '^756\\.\\d{4}\\.\\d{4}\\.\\d{2}$' // Swiss AHV
  • pattern: '^\\d{5}(-\\d{4})?$' // US ZIP

How it runs

Implementation

A faithful summary of lib/validators.ts. Validators are pure functions and run identically in the Worker, the Workbench and the MCP server — one implementation, so the three cannot disagree about whether a value is valid.

lib/validators.ts
function validRegex(value, params) {
  if (typeof params.pattern !== 'string') {
    return fail('regex_misconfigured', 'pattern not provided')
  }
  return new RegExp(params.pattern).test(value)
    ? OK
    : fail('regex_mismatch', `does not match ${params.pattern}`)
}

Config

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.

template.yaml
fields:
  - column: sku
    type: string
    validators:
      - type: regex
        pattern: '^[A-Z]{3}-\d{4}$'

Watch out

Common gotchas

  • JavaScript-flavour only. Lookbehind is fine on Node 20+, but POSIX classes like [[:alpha:]] are not.
  • No implicit anchors — write `^…$` yourself or the pattern will match substrings.
  • Empty values bypass all validators by design. Pair `required: true` with regex if you want to reject blanks.

Where it runs

Three routes, no AI cost.

  • POST/v1/validate-rowValidate one row against a template. Stateless, no key, pure compute — the fastest way to try regex against a real value.no key
  • POST/v1/uploads/:id/validateRun every field validator over the parsed upload, without committing. Returns errors and warnings per row.read
  • POST/v1/uploads/:id/commitValidates on the way out. skip_invalid_rows drops the failures instead of failing the commit.commit

Validators are pure functions, so they add nothing to the AI bill. Every map draws a small flat per-map fee from your prepaid token wallet ($10 minimum, shared across the phi-cloud suite); only columns that reach the metered LLM layer, plus any-to-any convert and structural reshape, bill real AI tokens. See pricing

Catalogue

Related templates

  • Employee rosteremployee_roster_v1

    Names, AHV/GLN, contract type, address.

    Fields · ahv_number

  • Patient demographicspatient_demographics_v1

    Patient identity. Emits FHIR Patient.

    Fields · ahv_number

  • Paymentspayments_v1

    Masked card payments: brand, last 4 digits, amount, processor reference. PCI scope — full PAN must NEVER be imported, only the last 4 digits.

    Fields · card_last4

  • KYC profileskyc_profiles_v1

    Know-Your-Customer identity profiles with risk rating. Contains PII.

    Fields · national_id

  • Employeesemployees_v1

    Employee master records with identity, contact, and bank details. Contains PII.

    Fields · national_id

Explore

All 19 validator types

The complete list a template field can declare. There is no SNOMED validator — it required an affiliate licence, no template used it, and it was removed in 2026.

Ready when you are

Validate every row — before it lands.

Attach checksum-strict validators to any field, and gate risky commits behind the requires_hitl flag. One key runs the whole cascade.

Prepaid token wallet · schema-only data-minimization mode · no free tier
regex validator — AdaptivMapr