Skip to content

Shared validation

Routes declare wire validation once. Codegen gives the frontend the same types (and, with exports, named runtyp preds) so forms and RPC stay in sync.

WhatWhereWho uses it
RPC methodsspec({ routes })Server + generated ApiClient
Shared domain entitiesschemas/ (or similar) — Product, User, …Imported by route input / output
Route-specific wire shapesRoute file — IDs, filters, one-off wrappersThat route’s generated {Route}Input / output types
Shared UI slicesspec({ exports })Filters, modals — same pred as server
UI-only fieldsConsumer appNever in the spec

Share domain preds like Product across routes; keep method-specific shapes (e.g. { id } lookup input) in the route file. exports is optional — register shared preds when the frontend should import them by name.

Register preds under exports when consumers should import them. Composition inside a route input does not auto-export the slice.

Powered by runtyp: preds validate on the server and serialize to JSON Schema for docs, OpenAPI, MCP, and codegen.

Generate validators with --validators — see SDK generation. Example layout: Server layout.