DocsValidators

enum validator

Reject any value not in an exact, case-sensitive allow-list.

Format

Membership test against an explicit `values` array. Comparison is strict equality — case-sensitive, whitespace-sensitive. Normalise upstream (lowercase, trim) if your data is dirty.

Examples

  • values: ['male', 'female', 'other', 'unknown']
  • values: ['permanent', 'fixed_term', 'apprentice']
  • values: ['USD', 'EUR', 'CHF']

Implementation

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

function validEnum(value, params) {
  const vs = Array.isArray(params.values) ? params.values : []
  return vs.includes(value)
    ? OK
    : fail('enum_invalid', `expected one of ${vs.join(', ')}`)
}

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: gender
    type: enum
    enum_values: [male, female, other, unknown]
    validators:
      - type: enum
        values: [male, female, other, unknown]

Common gotchas

  • Strict equality only — `Male` will fail against `male`. Lowercase in your transform first.
  • The validator does not consult `enum_values` on the field; you must pass `values` to the validator separately.
  • No partial match, no synonym mapping. Use a transform step for synonyms like `M → male`.

Related templates

No template in the default catalogue ships with enum preconfigured. Use it on a custom template via the YAML snippet above, or via the template editor.

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 →