Schema Types

▶ Open in Playground

Every builder function returns an immutable schema instance with a fluent API. Here are all available types:

BuilderDescriptionKey Methods
any()Accepts any value. Useful as a placeholder or for untyped fields..optional(), .default(value), .catch(value), .readonly(), .addValidator(fn)
string()String values with length and pattern constraints..minLength(n), .maxLength(n), .matches(re), .email(), .url(), .uuid(), .ip(), .trim(), .toLowerCase(), .nonempty(), .default(value), .catch(value), .readonly()
number()Numeric values with range and integer constraints..min(n), .max(n), .isInteger(), .positive(), .negative(), .finite(), .multipleOf(n)
boolean()Boolean values (true / false)..optional(), .default(value), .catch(value), .readonly()
date()Date values. Validates that the input is a valid Date instance..optional(), .default(value), .catch(value), .readonly()
func()Function values. Useful for callback props in component schemas..optional(), .default(value), .catch(value), .readonly()
nul()Exactly null. Useful for nullable union branches and JSON Schema interop..optional(), .default(value), .catch(value), .readonly()
object({...})Object schemas with named properties. The core building block for complex types..validate(data), .validateAsync(data), .addProps({...}), .optional(), .default(value), .catch(value), .readonly()
array(schema)Array of items matching the given element schema..minLength(n), .maxLength(n), .of(schema), .nonempty(), .unique(), .readonly()
tuple([...schemas])Fixed-length array with per-position types. Each index is validated against its own schema — mirrors TypeScript tuple types..rest(schema), .optional(), .nullable(), .default(value), .catch(value)
record(keySchema, valueSchema)Object with dynamic string keys — mirrors TypeScript's Record<K, V>. Every key must satisfy keySchema and every value must satisfy valueSchema. Use for lookup tables, i18n bundles, and any map-like structure whose keys are unknown at schema-definition time..optional(), .nullable(), .default(value), .catch(value), .addValidator(fn) validation result: .getErrorsFor(key?)
union(...schemas)Value must match one of the provided schemas (logical OR)..validate(data), .validateAsync(data), .optional(), .default(value), .catch(value), .readonly()
lazy(getter)Recursive / self-referential schema. The getter is called once and its result is cached. Essential for tree structures, comment threads, nested menus, and any type that references itself..resolve(), .optional(), .addValidator(fn), .addPreprocessor(fn), .default(value), .catch(value)