Docs · Validators

regex validator

Match a value against a JavaScript-flavour regular expression.

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

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

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.

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

Pricing

Validators run on every committed row

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

Ready when you are

Validate every row — before it lands.

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

Prepaid token wallet · schema-only data-minimization mode