Forms
Forms is the first domain of Schema Engine. It uses the registry for its elements, recipes and validation rules, actions for submit, reset and the work around them, and layout for the grid and named appearance. On top of those it adds what a form needs: fields and their values, validation rules, constraints between fields, steps, form state and the submit lifecycle. A form is a document: a JSON config that names registered elements by $type.
You build a form with createFormEngine from @schema-engine/forms and draw it with a renderer: Forms React or Forms Radiant. Both draw the same config, and the engine owns what the config means.
With the engine you can:
- Author form configs in TypeScript with
engine.defineForm(), typed from your registrations, or load them as JSON and check them withengine.validateForm(). - Register your own elements, view recipes, actions and validation rules.
- Validate values with the 27 validation rules the engine registers, and with rules of your own.
- Generate JSON Schema from what the engine has registered, for editors and tools.
What a form can do
A form's behavior is independent of the element that collects a value and the recipe that lays out the form. Every renderer implements the same form configuration contracts.
| Capability | Use it for | Start here |
|---|---|---|
| Constraints | Show, hide, enable, disable, or require a field from another value | Constraints |
| Validation | Required values, formats, ranges, and custom rules | Validation |
| Actions | Submit, reset, notifications, and ordered side effects | Actions overview |
| Async validation | Debounced remote checks, dependency values, and failure handling | Async rule |
| Async actions | Pending, success, and failure states around a remote operation | Submit, notify and reset |
| Dynamic fields | Repeatable groups and nested field scopes | Register a container |
| Form state | Values, field state, validity and submission, the same in both renderers | Form state |
| Wizard steps | Next, back and jump, with steps skipped from earlier answers | Wizard |
| Server errors | Show a server's validation response on the fields it names | Server errors |
| Issue text | Word every error and warning in your language | Issue text |
| CSRF | Send a token with the engine's requests and native posts | CSRF |
Installation and quick start
pnpm add @schema-engine/forms zodInstallation and quick start creates an engine with the elements of a renderer, checks a form loaded as JSON and renders it. The zod package provides the zod/mini entry point that first-party schemas use. Registrations may use any Standard Schema validator.
Where to go next
- Installation and quick start - Create the engine, check a form loaded as JSON and render it
- Engine and registrations - createFormEngine, registrations, typed authoring and configuration errors
- Constraints - Show, hide, enable, disable or require a field from another value
- Validation - The 27 built-in rules and presets
- Custom and async rules - Your own rules, a server check and testing
- Actions - The actions a form ships and how its submit runs them
- Form state - What a form holds, and how to read it from React and Radiant
- Issue text - Word errors and warnings in your language
- Wizard - Step navigation, skippable steps and a stepper of your own
- Server errors - Show a server's answer on the fields it names
- CSRF - Send your framework's token with requests and native posts
- Other React state - Mount a form in a panel that holds other state
- For AI agents - The guide an AI agent reads, shipped in the package
- Browser helpers - Consent-aware drafts and analytics events
- Write a renderer - For the author of a renderer: the runtime and the state container
- Agent tools - Offer a rendered form to a browser agent as a WebMCP tool
- Layout - Grid, appearance axes, theming and copy-paste examples
- YAML forms - Author forms in YAML with errors that point at the line
- API reference - Complete API documentation