Validation

Zod validators, or pure-JSON rules with custom messages.

GitHub

A field can be validated two ways. Both surface errors the way ui.errors dictates (inline / toast / popup).

Zod (validation)

Attach any Zod validator to a field. This is the most expressive option and integrates directly with React Hook Form's resolver:

import { z } from 'zod'

{ name: 'email', type: 'email', label: 'Email', validation: z.string().email() }
{ name: 'age',   type: 'number', label: 'Age',   validation: z.number().min(18).max(99) }

JSON rules (rules)

When you'd rather not import Zod for a field — or you're authoring the schema as data — declare rules. Pure JSON, with a custom error message per field:

{
  "name": "age",
  "type": "number",
  "label": "Age",
  "rules": { "required": true, "min": 18, "max": 99, "message": "Enter an age 18–99" }
}

Supported keys:

KeyApplies toMeaning
requiredanyvalue must be present
emailtext/emailmust be a valid email
patterntextregex source string, e.g. "^[0-9]+$"
minLength / maxLengthtextstring length bounds
min / maxnumbernumeric bounds
messageanyoverrides the default text for any failed rule on this field

If both are present on a field, the Zod validation winsrules is used only when validation is absent.

On this page