Creating a formController
sicilian provides a collection of tools for managing forms called the formController. Obtain the controller via the CreateForm class or the useForm hook. They differ only in lifecycle semantics: CreateForm is external to components while useForm is component-bound. Both accept an initialization object with optional properties: initValue, resolver, validator, validateOn, and clearFormOn.
initValue#
The initValue option supplies initial values for inputs and helps TypeScript infer field shapes. Initial values can be empty strings, defaults, or API-fetched data; checkboxes and radios can also be initialized.
resolver#
The resolver option enables declarative validation rules, for example using zodResolver with zod. Use it to define email format checks, string length, password complexity, required fields, and field relationships (e.g., .refine()).
validator#
The validator object defines per-field validation rules. It complements resolver-based schema validation and can be used independently for conditional or dynamic checks. See the resolver and validator page for details.
validateOn#
validateOn controls when validation runs: any combination of change, blur, and submit. Choose combinations that balance instant feedback and user experience.
clearFormOn#
CreateForm-produced controllers are independent of component lifecycle, so use clearFormOn to decide when to reset stored data: submit clears after submit, while routeChange clears on navigation. Note: routeChange currently works in React Router and Next.js Page Router/App Router environments.