createResolver
createResolver(
fields,fieldOverrides?,children?):Resolver<FieldValues>
Defined in: packages/forms/src/resolver.ts:131
Create a react-hook-form resolver that validates form values against introspected FieldDefinition rules.
Checks required fields, string length constraints, numeric range constraints,
regex patterns, and any custom validate functions from FieldConfig overrides.
Schema-derived rules (from introspectTable) and custom rules (from v)
are both enforced.
If children is provided, the resolver also validates each child row against
its introspected schema and enforces minRows / maxRows constraints.
Computed fields (those with fieldOverrides[name].computed) are skipped; they
are derived from other form values rather than user input.
Parameters
Section titled “Parameters”fields
Section titled “fields”The FieldDefinition array to validate against (from introspectTable).
fieldOverrides?
Section titled “fieldOverrides?”Partial<Record<string, FieldConfig>>
Optional per-field FieldConfig overrides, including custom validate functions.
children?
Section titled “children?”Record<string, ChildTableConfig>
Optional child table configurations keyed by array name.
Returns
Section titled “Returns”Resolver<FieldValues>
A react-hook-form Resolver that validates form values and returns errors.
Example
Section titled “Example”import { introspectTable, createResolver } from "@cfast/forms";import { posts } from "./schema";import { useForm } from "react-hook-form";
const fields = introspectTable(posts);const resolver = createResolver(fields, { title: { validate: (v) => (v === "test" ? "No test titles" : undefined) },});const form = useForm({ resolver });