DocsValidators

regex validator

Match a value against a JavaScript-flavour regular expression.

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

Implementation

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

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}`)
}

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: sku
    type: string
    validators:
      - type: regex
        pattern: '^[A-Z]{3}-\d{4}$'

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.

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

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 →