# Formisch > The lightweight, schema-first and fully type-safe form library for Angular, Preact, Qwik, React, React Native, Solid, Svelte and Vue. ## Runes ### createForm Creates a reactive form store from a form configuration. The form store manages form state and provides reactive properties. ```ts const form = createForm(config); ``` #### Generics - `TSchema` `extends FormSchema` #### Parameters - `config` `FormConfig` ##### Explanation `createForm` creates a reactive form store that manages form state using the provided Valibot schema. Validation runs when the form is submitted by default, but this can be customized with the `validate` and `revalidate` options. #### Returns - `form` `FormStore` #### Related The following APIs can be combined with `createForm`. ##### Runes [`useField`](/svelte/api/useField.md), [`useFieldArray`](/svelte/api/useFieldArray.md) ##### Components [`Field`](/svelte/api/Field.md), [`FieldArray`](/svelte/api/FieldArray.md), [`Form`](/svelte/api/Form.md) ##### Methods [`focus`](/methods/api/focus.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`getErrors`](/methods/api/getErrors.md), [`getInput`](/methods/api/getInput.md), [`handleSubmit`](/methods/api/handleSubmit.md), [`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md), [`reset`](/methods/api/reset.md), [`setErrors`](/methods/api/setErrors.md), [`setInput`](/methods/api/setInput.md), [`submit`](/methods/api/submit.md), [`swap`](/methods/api/swap.md), [`validate`](/methods/api/validate.md) ### useField Creates a reactive field store for a specific field within a form store. ```ts const field = useField(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Parameters - `form` `MaybeGetter>` - `config` `MaybeGetter>` ##### Explanation With `useField` you create a reactive field store for a specific field path within your form. The field store provides reactive access to the field's input value, validation errors, touched state, and more. It also includes a `props` object that you can spread onto an HTML input or textarea element to automatically handle user interactions like focus, blur, and input events. #### Returns - `field` `FieldStore` #### Related The following APIs can be combined with `useField`. ##### Runes [`createForm`](/svelte/api/createForm.md), [`useFieldArray`](/svelte/api/useFieldArray.md) ##### Components [`Field`](/svelte/api/Field.md), [`FieldArray`](/svelte/api/FieldArray.md), [`Form`](/svelte/api/Form.md) ##### Methods [`focus`](/methods/api/focus.md), [`getErrors`](/methods/api/getErrors.md), [`getInput`](/methods/api/getInput.md), [`setErrors`](/methods/api/setErrors.md), [`setInput`](/methods/api/setInput.md), [`validate`](/methods/api/validate.md) ### useFieldArray Creates a reactive field array store for a specific field array within a form store. ```ts const fieldArray = useFieldArray(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Parameters - `form` `MaybeGetter>` - `config` `MaybeGetter>` ##### Explanation With `useFieldArray` you create a reactive field array store for a specific array field within your form. The field array store provides reactive access to the array items (by their IDs), validation errors, touched state, and more. This is particularly useful when working with dynamic arrays of fields that users can add or remove. #### Returns - `fieldArray` `FieldArrayStore` #### Related The following APIs can be combined with `useFieldArray`. ##### Runes [`createForm`](/svelte/api/createForm.md), [`useField`](/svelte/api/useField.md) ##### Components [`Field`](/svelte/api/Field.md), [`FieldArray`](/svelte/api/FieldArray.md), [`Form`](/svelte/api/Form.md) ##### Methods [`focus`](/methods/api/focus.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`getErrors`](/methods/api/getErrors.md), [`getInput`](/methods/api/getInput.md), [`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md), [`reset`](/methods/api/reset.md), [`setErrors`](/methods/api/setErrors.md), [`setInput`](/methods/api/setInput.md), [`swap`](/methods/api/swap.md), [`validate`](/methods/api/validate.md) ## Components ### Form Form component that manages form submission and applies internal state. It wraps a native form element and calls the provided handler with the validated form output and the submit event. ```svelte
children
``` #### Generics - `TSchema` `extends FormSchema` #### Properties - `of` `FormStore` - `children` `Snippet` - `onsubmit` `SubmitEventHandler` ##### Explanation The `Form` component wraps a native HTML `
` element and provides form submission handling. It automatically prevents the default form submission behavior and calls the `onsubmit` handler when the form is submitted and validation succeeds. The component uses the `of` prop to reference the form store and renders the `children` elements within the form. It also sets `novalidate` on the form element to disable browser validation, as Formisch handles validation internally. #### Related ##### Runes [`createForm`](/svelte/api/createForm.md) ##### Components [`Field`](/svelte/api/Field.md), [`FieldArray`](/svelte/api/FieldArray.md) ##### Methods [`focus`](/methods/api/focus.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`getErrors`](/methods/api/getErrors.md), [`handleSubmit`](/methods/api/handleSubmit.md), [`reset`](/methods/api/reset.md), [`setErrors`](/methods/api/setErrors.md), [`setInput`](/methods/api/setInput.md), [`submit`](/methods/api/submit.md), [`validate`](/methods/api/validate.md) ### Field Headless form field component that provides reactive properties and state. The field component takes a form store, path to field, and a snippet that receives a field store to display field state and handle user interactions. ```svelte children ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Properties - `of` `FormStore` - `path` `ValidPath, TFieldPath>` - `children` `Snippet<[FieldStore]>` ##### Explanation The `Field` component is a headless component that doesn't render any UI itself. Instead, it accepts a `children` snippet and invokes it with a [`FieldStore`](/svelte/api/FieldStore.md) containing all the reactive state and props needed to render a form field. The component automatically handles field registration, validation, and state management through the `of` prop that references the form store. #### Related ##### Runes [`createForm`](/svelte/api/createForm.md), [`useField`](/svelte/api/useField.md) ##### Components [`Form`](/svelte/api/Form.md), [`FieldArray`](/svelte/api/FieldArray.md) ### FieldArray Headless field array component that provides reactive properties and state for managing array fields. The field array component takes a form store, path to array field, and a snippet that receives a field array store to manage array items and handle array operations. ```svelte children ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Properties - `of` `FormStore` - `path` `ValidArrayPath, TFieldArrayPath>` - `children` `Snippet<[FieldArrayStore]>` ##### Explanation The `FieldArray` component is a headless component that doesn't render any UI itself. Instead, it accepts a `children` snippet and invokes it with a [`FieldArrayStore`](/svelte/api/FieldArrayStore.md) containing the reactive state of the array field, such as its item IDs and validation errors. The items themselves are manipulated with the form methods listed below. The component automatically handles array field registration, validation, and state management through the `of` prop that references the form store. #### Related ##### Runes [`createForm`](/svelte/api/createForm.md), [`useFieldArray`](/svelte/api/useFieldArray.md) ##### Components [`Field`](/svelte/api/Field.md), [`Form`](/svelte/api/Form.md) ##### Methods [`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md), [`swap`](/methods/api/swap.md) ## Methods ### focus Focuses the first focusable input element of a field. This is useful for programmatically setting focus to a specific field, such as after validation errors or user interactions. ```ts focus(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Parameters - `form` `BaseFormStore` - `config` `FocusFieldConfig` ##### Explanation The `form` parameter is the form store containing the field to focus. The `config` parameter specifies which field to focus using the `path` property. #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`validate`](/methods/api/validate.md), [`setErrors`](/methods/api/setErrors.md) ### getDeepError Retrieves the first error message of a specific field or the entire form by walking through the field store and all its descendants and stopping at the first field with errors. This is useful for displaying a single error message for a field whose value is a nested structure, such as a rich text editor or tags input. ```ts const error = getDeepError(form); const error = getDeepError(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormDeepErrorConfig | GetFieldDeepErrorConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve the error from. The optional `config` parameter scopes the search to a specific field's subtree via a `path` (when omitted, the entire form is walked). The function walks through the field store and all its descendants in depth-first order and stops at the first field with errors, so errors of a field surface before errors of its descendants. #### Returns - `result` `string | null` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getErrors`](/methods/api/getErrors.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md), [`validate`](/methods/api/validate.md) ### getDeepErrorEntries Retrieves the errors of a specific field or the entire form as a list of entries, each pairing the path to a field with its error messages. This is useful for building custom error summaries that link each message back to its field. ```ts const entries = getDeepErrorEntries(form); const entries = getDeepErrorEntries(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormDeepErrorEntriesConfig | GetFieldDeepErrorEntriesConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve error entries from. The optional `config` parameter scopes the collection to a specific field's subtree via a `path` (when omitted, the entire form is walked). Each returned entry contains the `path` to a field and its non-empty list of `errors`. #### Returns - `result` `DeepErrorEntry>[]` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getErrors`](/methods/api/getErrors.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md), [`validate`](/methods/api/validate.md) ### getDeepErrorEntry Retrieves the errors of the first erroring field of a specific field or the entire form as an entry pairing the path to the field with its error messages, by walking through the field store and all its descendants and stopping at the first field with errors. This is useful for locating the first erroring descendant of a field whose value is a nested structure while retaining all errors at that path. ```ts const entry = getDeepErrorEntry(form); const entry = getDeepErrorEntry(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormDeepErrorEntryConfig | GetFieldDeepErrorEntryConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve the error entry from. The optional `config` parameter scopes the search to a specific field's subtree via a `path` (when omitted, the entire form is walked). The function walks through the field store and all its descendants in depth-first order and stops at the first field with errors, so errors of a field surface before errors of its descendants. The returned entry contains the `path` to the field and its non-empty list of `errors`. Form-level errors are included with an empty path. #### Returns - `result` `DeepErrorEntry> | null` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getErrors`](/methods/api/getErrors.md), [`getDeepError`](/methods/api/getDeepError.md), [`getDeepErrorEntries`](/methods/api/getDeepErrorEntries.md), [`validate`](/methods/api/validate.md) ### getDeepErrors Retrieves all error messages of a specific field or the entire form by walking through the field store and all its descendants. This is useful for displaying a summary of all validation errors within a section or the whole form. ```ts const errors = getDeepErrors(form); const errors = getDeepErrors(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormDeepErrorsConfig | GetFieldDeepErrorsConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve errors from. The optional `config` parameter scopes the collection to a specific field's subtree via a `path` (when omitted, the entire form is walked). The function walks through the field store and all its descendants to collect every validation error message. #### Returns - `result` `[string, ...string[]] | null` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getErrors`](/methods/api/getErrors.md), [`getDeepError`](/methods/api/getDeepError.md), [`getDeepErrorEntries`](/methods/api/getDeepErrorEntries.md), [`validate`](/methods/api/validate.md), [`setErrors`](/methods/api/setErrors.md) ### getDirtyInput Retrieves only the dirty input values of a specific field or the entire form. Object keys whose subtree contains no dirty descendant are omitted; arrays are treated as atomic and returned in full whenever any descendant is dirty. Returns `undefined` if no field in the inspected subtree is dirty. ```ts const input = getDirtyInput(form); const input = getDirtyInput(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormDirtyInputConfig | GetFieldDirtyInputConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve dirty input from. The optional `config` parameter scopes the result to a specific field path - if omitted, returns dirty input from the entire form. The returned value is a partial of the inspected input shape containing only the fields whose `isDirty` flag is set, which is useful for submitting only the values that changed since the start input. Arrays are treated as atomic — when any descendant of an array is dirty, the full current array is returned. Internally, the function walks the form's field tree and asks `getFieldBool` whether each branch contains a dirty descendant. Because that check is itself recursive, the cost is effectively linear in field count for typical balanced forms (shallow and wide) and degrades toward `O(N²)` for deeply nested trees. Call this method from submit or blur handlers rather than from tight reactive loops on large forms. #### Returns - `result` `DeepPartial> | undefined` #### Related ##### Methods [`getDirtyPaths`](/methods/api/getDirtyPaths.md), [`getInput`](/methods/api/getInput.md), [`pickDirty`](/methods/api/pickDirty.md), [`reset`](/methods/api/reset.md) ### getDirtyPaths Returns a list of paths to dirty fields in the form. Object branches are recursed into; arrays are treated as atomic — when any descendant of an array is dirty, only the array's own path is returned. ```ts const paths = getDirtyPaths(form); const paths = getDirtyPaths(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormDirtyPathsConfig | GetFieldDirtyPathsConfig | undefined` ##### Explanation The `form` parameter is the form store to inspect. The optional `config` parameter scopes the search to a single subtree via its `path` property. Object branches are recursed into and clean keys are omitted; arrays are atomic, so when any descendant of an array is dirty, the result includes the array's own path rather than the paths of its individual items. Returns an empty array if the inspected subtree contains no dirty fields. When `path` targets a dirty array or value field, the result contains that path. Internally, the function collects the paths in a single recursive walk that visits each field at most once, so the cost is linear in the number of fields in the inspected subtree. #### Returns - `result` `DirtyPath>[]` #### Related ##### Methods [`getDirtyInput`](/methods/api/getDirtyInput.md), [`getInput`](/methods/api/getInput.md), [`pickDirty`](/methods/api/pickDirty.md) ### getErrors Retrieves error messages from the form. When called without a config, returns form-level errors. When called with a path, returns errors for that specific field. ```ts const errors = getErrors(form); const errors = getErrors(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormErrorsConfig | GetFieldErrorsConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve errors from. The optional `config` parameter specifies which errors to retrieve - either form-level errors (when omitted) or field-specific errors (when a `path` is provided). #### Returns - `result` `[string, ...string[]] | null` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getDeepErrors`](/methods/api/getDeepErrors.md), [`setErrors`](/methods/api/setErrors.md), [`validate`](/methods/api/validate.md) ### getInput Retrieves the current input value of a specific field or the entire form. Returns a partial object as not all fields may have been set. ```ts const input = getInput(form); const input = getInput(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `GetFormInputConfig | GetFieldInputConfig | undefined` ##### Explanation The `form` parameter is the form store to retrieve input from. The optional `config` parameter specifies which field to get input from - if omitted, returns input from the entire form. #### Returns - `result` `PartialValues>` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`setInput`](/methods/api/setInput.md), [`reset`](/methods/api/reset.md) ### handleSubmit Creates a submit event handler for the form that prevents default browser submission, validates the form input, and calls the provided handler if validation succeeds. This is designed to be used with the form's onsubmit event. ```ts const result = handleSubmit(form, handler); ``` > In React Native, where there is no form element or submit event, `handleSubmit` returns a plain async function that you call from a button's `onPress` or a text input's `onSubmitEditing` handler. In this case the handler receives only the validated form output — there is no event object. #### Generics - `TSchema` `extends FormSchema` #### Parameters - `form` `BaseFormStore` - `handler` `SubmitHandler | SubmitEventHandler` ##### Explanation The `form` parameter is the form store to handle submission for. The `handler` parameter can be a `SubmitHandler` (no event) or, in the frameworks that submit through a form element, a `SubmitEventHandler` (with event) that gets called with the validated form output if validation succeeds. In React Native only `SubmitHandler` applies, as there is no submit event. If the input changes, the form is fully reset, or a newer validation or submission starts before validation finishes, the outdated submission does not call its handler. A newer submission or full form reset also prevents an older handler from changing form errors or `isSubmitting` when it finishes. This does not abort a handler or network request that has already started. #### Returns - `result` `(() => Promise) | ((event: SubmitEvent) => Promise)` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`validate`](/methods/api/validate.md), [`focus`](/methods/api/focus.md), [`submit`](/methods/api/submit.md) ### insert Inserts a new item into a field array at the specified index. All items at or after the insertion point are shifted up by one index. ```ts insert(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Parameters - `form` `BaseFormStore` - `config` `InsertConfig` ##### Explanation The `form` parameter is the form store containing the field array. The `config` parameter specifies the path to the field array, the index where to insert the new item, and optional initial input values for the new item. #### Related ##### Primitives [`useForm`](/react/api/useForm.md), [`useFieldArray`](/react/api/useFieldArray.md) ##### Methods [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md), [`swap`](/methods/api/swap.md) ### isDirty Checks whether a specific field or the entire form is dirty by walking through the field store and all its descendants. A field is dirty when its input differs from its initial value. ```ts const dirty = isDirty(form); const dirty = isDirty(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `IsFormDirtyConfig | IsFieldDirtyConfig | undefined` ##### Explanation The `form` parameter is the form store to check for dirtiness. The optional `config` parameter scopes the check to a specific field's subtree via a `path` (when omitted, the entire form is checked). The function walks through the field store and all its descendants and returns `true` as soon as it finds a dirty field. #### Returns - `result` `boolean` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getDirtyInput`](/methods/api/getDirtyInput.md), [`getDirtyPaths`](/methods/api/getDirtyPaths.md), [`pickDirty`](/methods/api/pickDirty.md), [`isTouched`](/methods/api/isTouched.md), [`isEdited`](/methods/api/isEdited.md), [`isValid`](/methods/api/isValid.md) ### isEdited Checks whether a specific field or the entire form is edited by walking through the field store and all its descendants. A field is edited once its value has been changed by the user. ```ts const edited = isEdited(form); const edited = isEdited(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `IsFormEditedConfig | IsFieldEditedConfig | undefined` ##### Explanation The `form` parameter is the form store to check for being edited. The optional `config` parameter scopes the check to a specific field's subtree via a `path` (when omitted, the entire form is checked). The function walks through the field store and all its descendants and returns `true` as soon as it finds an edited field. #### Returns - `result` `boolean` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`isDirty`](/methods/api/isDirty.md), [`isTouched`](/methods/api/isTouched.md), [`isValid`](/methods/api/isValid.md) ### isTouched Checks whether a specific field or the entire form is touched by walking through the field store and all its descendants. A field is touched once it has received focus or its value has been changed. ```ts const touched = isTouched(form); const touched = isTouched(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `IsFormTouchedConfig | IsFieldTouchedConfig | undefined` ##### Explanation The `form` parameter is the form store to check for being touched. The optional `config` parameter scopes the check to a specific field's subtree via a `path` (when omitted, the entire form is checked). The function walks through the field store and all its descendants and returns `true` as soon as it finds a touched field. #### Returns - `result` `boolean` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`isDirty`](/methods/api/isDirty.md), [`isEdited`](/methods/api/isEdited.md), [`isValid`](/methods/api/isValid.md), [`focus`](/methods/api/focus.md) ### isValid Checks whether a specific field or the entire form is valid by walking through the field store and all its descendants. A field is valid when neither it nor any of its descendants contains an error. ```ts const valid = isValid(form); const valid = isValid(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `IsFormValidConfig | IsFieldValidConfig | undefined` ##### Explanation The `form` parameter is the form store to check for validity. The optional `config` parameter scopes the check to a specific field's subtree via a `path` (when omitted, the entire form is checked). The function walks through the field store and all its descendants and returns `false` as soon as it finds an error. #### Returns - `result` `boolean` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getErrors`](/methods/api/getErrors.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`isDirty`](/methods/api/isDirty.md), [`isTouched`](/methods/api/isTouched.md), [`isEdited`](/methods/api/isEdited.md) ### move Moves an item within a field array from one index to another. All items between the old and new positions are shifted accordingly. ```ts move(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Parameters - `form` `BaseFormStore` - `config` `MoveConfig` ##### Explanation The `form` parameter is the form store containing the field array. The `config` parameter specifies the path to the field array and the indices to move the item from and to. #### Related ##### Primitives [`useForm`](/react/api/useForm.md), [`useFieldArray`](/react/api/useFieldArray.md) ##### Methods [`insert`](/methods/api/insert.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md), [`swap`](/methods/api/swap.md) ### pickDirty Picks only the dirty parts of the given value, using the form's dirty tree as a structural mask. Object keys whose subtree contains no dirty descendant are omitted; arrays are treated as atomic and returned in full whenever any descendant is dirty. Returns `undefined` if no field is dirty. Where the supplied value's shape diverges from the form's input shape — for example, a field expected to be an object holds a primitive, `null` or array — that branch is returned as-is. Useful for filtering a validated output to just the changed parts before submitting. ```ts const dirty = pickDirty(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TValue` `extends object` #### Parameters - `form` `BaseFormStore` - `config` `PickDirtyConfig` ##### Explanation The `form` parameter is the form store providing the dirty mask. The `config` parameter must include a `from` value to filter. The value's shape is expected to match the form's input shape — wherever the shapes diverge (e.g. an object key in the form holds a primitive, `null` or array in the supplied value), that branch is returned as-is so the divergence is preserved in the result. Use this when a Valibot schema transformation produces a value of a different shape than the form's input and you want to ship only the dirty parts of that output. Internally, the function walks the form's field tree alongside the supplied value, using `getFieldBool` to skip clean subtrees and a constant-time check at each node to verify shape alignment. Because the dirty check is itself recursive, the cost is effectively linear in field count for typical balanced forms (shallow and wide) and degrades toward `O(N²)` for deeply nested trees. Call this method from submit or blur handlers rather than from tight reactive loops on large forms. #### Returns - `result` `DeepPartial | undefined` #### Related ##### Methods [`getDirtyInput`](/methods/api/getDirtyInput.md), [`getDirtyPaths`](/methods/api/getDirtyPaths.md), [`getInput`](/methods/api/getInput.md) ### remove Removes an item from a field array at the specified index. All items after the removed index are shifted down by one. ```ts remove(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Parameters - `form` `BaseFormStore` - `config` `RemoveConfig` ##### Explanation The `form` parameter is the form store containing the field array. The `config` parameter specifies the path to the field array and the index of the item to remove. #### Related ##### Primitives [`useForm`](/react/api/useForm.md), [`useFieldArray`](/react/api/useFieldArray.md) ##### Methods [`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`replace`](/methods/api/replace.md), [`swap`](/methods/api/swap.md) ### replace Replaces an item in a field array at the specified index with a new item. ```ts replace(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Parameters - `form` `BaseFormStore` - `config` `ReplaceConfig` ##### Explanation The `form` parameter is the form store containing the field array. The `config` parameter specifies the path to the field array, the index of the item to replace, and the new item values. #### Related ##### Primitives [`useForm`](/react/api/useForm.md), [`useFieldArray`](/react/api/useFieldArray.md) ##### Methods [`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`swap`](/methods/api/swap.md) ### reset Resets the form or a specific field to its initial state or to a new initial input. Optionally keeps certain states like input values, touched state, or errors. ```ts reset(form); reset(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `ResetFormConfig | ResetFieldConfig | undefined` ##### Explanation When called without a config or with `path` set to `undefined`, the entire form is reset. When a `path` is provided, only that specific field and its nested fields are reset. By default, the form resets to its original initial input. However, you can pass a new `initialInput` in the config to update the form's baseline data. This is useful when remote data has changed and the form needs to reflect the updated values. Combined with `keepInput`, `keepTouched`, `keepEdited`, `keepErrors`, and `keepSubmitted`, you can update the initial state without overwriting the user's current edits. Resetting a field discards pending validation of the previous form input, including results for other fields. Existing errors on unrelated fields are preserved. Call [`validate`](/methods/api/validate.md) if you need fresh results immediately after a field reset. A full form reset clears `isSubmitting`. Pending submissions no longer call their handlers after validation finishes, and late exceptions from their validations or handlers do not update form errors. Resetting does not abort a handler or network request that has already started. ###### More context on dirty tracking Formisch distinguishes between two concepts: - **Initial input**: the baseline value used for dirty tracking (often the server state). - **Current input**: the value the user is currently editing (the client state). Calling `reset` updates the initial input (baseline). Depending on the `keep*` options, it can also overwrite the current input, or keep it and just recompute state like `isDirty` based on the new baseline. > If the initial input is `null` or `undefined`, Formisch does not treat an empty string or `NaN` as dirty. This helps when HTML inputs produce `''` or `NaN` for "empty" values. #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`setInput`](/methods/api/setInput.md), [`getInput`](/methods/api/getInput.md), [`setErrors`](/methods/api/setErrors.md), [`validate`](/methods/api/validate.md) ### setErrors Sets or clears error messages on the form or a specific field. This is useful for setting custom validation errors that don't come from schema validation. ```ts setErrors(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `SetFormErrorsConfig | SetFieldErrorsConfig` ##### Explanation The `form` parameter is the form store to set errors on. The `config` parameter specifies the path and the error messages to set. Set `errors` to `null` to clear existing errors. #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getErrors`](/methods/api/getErrors.md), [`getDeepErrors`](/methods/api/getDeepErrors.md), [`validate`](/methods/api/validate.md) ### setInput Sets input values for the form or a specific field programmatically. ```ts setInput(form, config); setInput(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath | undefined = undefined` #### Parameters - `form` `BaseFormStore` - `config` `SetFormInputConfig | SetFieldInputConfig` ##### Explanation The `form` parameter is the form store to set input on. The `config` parameter specifies the path to the field and the new input values to set. > `setInput` updates the **current input** (what the user is editing), but it does not change the **initial input** (the baseline used for `isDirty`). If your baseline data changes (e.g. after refetching from the server), prefer [`reset`](/methods/api/reset.md) with a new `initialInput`. Updating input discards pending validation results for the previous input. A new validation only starts when required by the form's validation mode. #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`getInput`](/methods/api/getInput.md), [`reset`](/methods/api/reset.md) ### submit Programmatically requests form submission by calling the native `requestSubmit()` method on the underlying form element. ```ts submit(form); ``` #### Parameters - `form` `BaseFormStore` ##### Explanation The `form` parameter is the form store to submit. The function triggers form submission by calling the native `requestSubmit()` method on the underlying form element. #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`handleSubmit`](/methods/api/handleSubmit.md), [`validate`](/methods/api/validate.md), [`focus`](/methods/api/focus.md) ### swap Swaps two items in a field array at the specified indices. ```ts swap(form, config); ``` #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Parameters - `form` `BaseFormStore` - `config` `SwapConfig` ##### Explanation The `form` parameter is the form store containing the field array. The `config` parameter specifies the path to the field array and the two indices of the items to swap. #### Related ##### Primitives [`useForm`](/react/api/useForm.md), [`useFieldArray`](/react/api/useFieldArray.md) ##### Methods [`insert`](/methods/api/insert.md), [`move`](/methods/api/move.md), [`remove`](/methods/api/remove.md), [`replace`](/methods/api/replace.md) ### validate Validates the entire form input against its schema. Returns a safe parse result indicating success or failure with detailed issues. Optionally focuses the first field with validation errors. ```ts const result = validate(form); const result = validate(form, config); ``` #### Generics - `TSchema` `extends FormSchema` #### Parameters - `form` `BaseFormStore` - `config` `ValidateFormConfig | undefined` ##### Explanation The `form` parameter is the form store to validate. The optional `config` parameter allows specifying whether to automatically focus the first field with validation errors after validation. #### Returns - `result` `Promise>` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`focus`](/methods/api/focus.md), [`handleSubmit`](/methods/api/handleSubmit.md), [`setErrors`](/methods/api/setErrors.md), [`getErrors`](/methods/api/getErrors.md), [`getDeepErrors`](/methods/api/getDeepErrors.md) ## Types ### DeepErrorEntry Entry that pairs the `path` to a field with its error messages. Returned by the `getDeepErrorEntries` and `getDeepErrorEntry` methods. Form-level errors are included with an empty path. #### Generics - `TValue` `extends unknown = unknown` #### Definition - `DeepErrorEntry` - `path` `unknown extends TValue ? Path : readonly [] | FieldPath` - `errors` `[string, ...string[]]` #### Related ##### Methods [`getDeepErrorEntries`](/methods/api/getDeepErrorEntries.md), [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md) ### DeepPartial A utility type that recursively makes all properties and nested properties optional. #### Generics - `TValue` `extends unknown` > This type is too complex to display. Please refer to the [source code](https://github.com/open-circle/formisch/blob/main/packages/core/src/types/utils/utils.ts). #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ### EmptyInput Empty input interface that defines the value a required field of a given type starts at when no initial input is provided. Optional and nullable fields are not affected, as they accept `undefined`. #### Definition - `EmptyInput` - `string` `string | undefined` - `number` `number | undefined` - `boolean` `boolean | undefined` - `date` `Date | undefined` ##### Explanation Only required fields whose input is `undefined` fall back to these values. The `string` property defaults to an empty string so that an untouched field matches the DOM and validates with its own message instead of a type mismatch. The other properties default to `undefined`. #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Types [`FormConfig`](/react/api/FormConfig.md) ### FieldArrayStore Reactive field array store interface with properties for managing array fields. #### Generics - `TSchema` `extends FormSchema = FormSchema` - `TFieldArrayPath` `extends RequiredPath = RequiredPath` #### Definition - `FieldArrayStore` - `path` `ValidArrayPath, TFieldArrayPath>` - `items` `string[]` - `errors` `[string, ...string[]] | null` - `isTouched` `boolean` - `isEdited` `boolean` - `isDirty` `boolean` - `isValid` `boolean` ### FieldElement A union type representing form field elements that can be registered with a field store. #### Definition - `FieldElement` `HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement` #### Related ##### Methods [`focus`](/methods/api/focus.md) ### FieldElementProps Props to spread onto a field element for integration with Svelte form handling. #### Definition - `FieldElementProps` - `name` `string` - `autofocus` `boolean` - `[ref: symbol]` `(element: FieldElement) => () => void` - `onfocus` `() => void` - `oninput` `FormEventHandler` - `onchange` `FormEventHandler` - `onblur` `() => void` ##### Explanation `onfocus` marks the field as touched and runs the configured `'touch'` validation, while `onblur` runs the configured `'blur'` validation. Neither handler uses the event object, so both are typed as `() => void` and can be passed to native elements or custom components with different focus event types. ### FieldStore Reactive field store interface with properties and element props for field management. #### Generics - `TSchema` `extends FormSchema = FormSchema` - `TFieldPath` `extends RequiredPath = RequiredPath` #### Definition - `FieldStore` - `path` `ValidPath, TFieldPath>` - `input` `PartialValues, TFieldPath>>` - `errors` `[string, ...string[]] | null` - `isTouched` `boolean` - `isEdited` `boolean` - `isDirty` `boolean` - `isValid` `boolean` - `onInput` `(value: PartialValues, TFieldPath>>) => void` - `props` `FieldElementProps` ### FocusFieldConfig Configuration interface for focusing a field. Used by the `focus` method to specify which field to focus. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `FocusFieldConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`focus`](/methods/api/focus.md) ### FormConfig Form config interface that defines the configuration options for creating a form store with [`createForm`](/svelte/api/createForm.md). #### Generics - `TSchema` `extends FormSchema = FormSchema` #### Definition - `FormConfig` - `schema` `TSchema` - `initialInput` `DeepPartial> | undefined` - `emptyInput` `EmptyInput | undefined` - `validate` `ValidationMode | undefined` - `revalidate` `Exclude | undefined` ##### Explanation The `FormConfig` object is passed to [`createForm`](/svelte/api/createForm.md) with a required `schema` property and optional properties for `initialInput`, `emptyInput`, `validate`, and `revalidate` to control form behavior and validation timing. ### FormSchema Type definition that represents the Valibot schemas allowed as the root of a form. Forms must have an object root, so this is constrained structurally to any schema with an object output rather than to specific schema types. This includes object schemas, combinators (`intersect`, `union`, `variant`) over objects, `lazy` schemas wrapping any of these, and generic object schemas like `v.GenericSchema<{ … }>`. Use [Schema](/core/api/Schema.md) for nested field schemas. #### Definition - `FormSchema` `GenericSchema> | GenericSchemaAsync>` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`validate`](/methods/api/validate.md) ### FormStore Form store interface that provides reactive access to the state of a form created with [`createForm`](/svelte/api/createForm.md). #### Generics - `TSchema` `extends FormSchema = FormSchema` #### Definition - `FormStore` - `isSubmitting` `boolean` - `isSubmitted` `boolean` - `isValidating` `boolean` - `isTouched` `boolean` - `isEdited` `boolean` - `isDirty` `boolean` - `isValid` `boolean` - `errors` `[string, ... string[]] | null` ##### Explanation The `errors` property only contains validation errors at the root level of the form. These are errors from the root object schema validation itself, not errors from nested fields. To retrieve all validation errors from all fields across the entire form, use the [`getDeepErrors`](/methods/api/getDeepErrors.md) method instead. ### GetFieldDeepErrorConfig Configuration interface for retrieving the first error of a specific field. Used by the `getDeepError` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldDeepErrorConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getDeepError`](/methods/api/getDeepError.md) ### GetFieldDeepErrorEntriesConfig Configuration interface for retrieving the error entries of a specific field. Used by the `getDeepErrorEntries` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldDeepErrorEntriesConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getDeepErrorEntries`](/methods/api/getDeepErrorEntries.md) ### GetFieldDeepErrorEntryConfig Configuration interface for retrieving the first error entry of a specific field. Used by the `getDeepErrorEntry` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldDeepErrorEntryConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md) ### GetFieldDeepErrorsConfig Configuration interface for retrieving the errors of a specific field. Used by the `getDeepErrors` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldDeepErrorsConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getDeepErrors`](/methods/api/getDeepErrors.md) ### GetFieldDirtyInputConfig Configuration interface for retrieving field-scoped dirty input. Used by the `getDirtyInput` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldDirtyInputConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getDirtyInput`](/methods/api/getDirtyInput.md) ### GetFieldDirtyPathsConfig Configuration interface for inspecting field-scoped dirty paths. Used by the `getDirtyPaths` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldDirtyPathsConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getDirtyPaths`](/methods/api/getDirtyPaths.md) ### GetFieldErrorsConfig Configuration interface for retrieving field-specific errors. Used by the `getErrors` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldErrorsConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getErrors`](/methods/api/getErrors.md) ### GetFieldInputConfig Configuration interface for retrieving field-specific input. Used by the `getInput` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `GetFieldInputConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`getInput`](/methods/api/getInput.md) ### GetFormDeepErrorConfig Configuration interface for retrieving the first error of the entire form. Used by the `getDeepError` method when no specific field path is provided. #### Definition - `GetFormDeepErrorConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getDeepError`](/methods/api/getDeepError.md) ### GetFormDeepErrorEntriesConfig Configuration interface for retrieving the error entries of the entire form. Used by the `getDeepErrorEntries` method when no specific field path is provided. #### Definition - `GetFormDeepErrorEntriesConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getDeepErrorEntries`](/methods/api/getDeepErrorEntries.md) ### GetFormDeepErrorEntryConfig Configuration interface for retrieving the first error entry of the entire form. Used by the `getDeepErrorEntry` method when no specific field path is provided. #### Definition - `GetFormDeepErrorEntryConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getDeepErrorEntry`](/methods/api/getDeepErrorEntry.md) ### GetFormDeepErrorsConfig Configuration interface for retrieving the errors of the entire form. Used by the `getDeepErrors` method when no specific field path is provided. #### Definition - `GetFormDeepErrorsConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getDeepErrors`](/methods/api/getDeepErrors.md) ### GetFormDirtyInputConfig Configuration interface for retrieving form-level dirty input. Used by the `getDirtyInput` method when no specific field path is provided. #### Definition - `GetFormDirtyInputConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getDirtyInput`](/methods/api/getDirtyInput.md) ### GetFormDirtyPathsConfig Configuration interface for inspecting form-level dirty paths. Used by the `getDirtyPaths` method when no specific field path is provided. #### Definition - `GetFormDirtyPathsConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getDirtyPaths`](/methods/api/getDirtyPaths.md) ### GetFormErrorsConfig Configuration interface for retrieving form-level errors. Used by the `getErrors` method when no specific field path is provided. #### Definition - `GetFormErrorsConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getErrors`](/methods/api/getErrors.md) ### GetFormInputConfig Configuration interface for retrieving form-level input. Used by the `getInput` method when no specific field path is provided. #### Definition - `GetFormInputConfig` - `path` `undefined = undefined` #### Related ##### Methods [`getInput`](/methods/api/getInput.md) ### InsertConfig Configuration interface for inserting items into array fields. Used by the `insert` method. #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Definition - `InsertConfig` - `path` `ValidArrayPath, TFieldArrayPath>` - `at` `number | undefined` - `initialInput` `DeepPartial, [...TFieldArrayPath, number]>> | undefined` #### Related ##### Methods [`insert`](/methods/api/insert.md) ### IsFieldDirtyConfig Configuration interface for checking whether a specific field is dirty. Used by the `isDirty` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `IsFieldDirtyConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`isDirty`](/methods/api/isDirty.md) ### IsFieldEditedConfig Configuration interface for checking whether a specific field is edited. Used by the `isEdited` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `IsFieldEditedConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`isEdited`](/methods/api/isEdited.md) ### IsFieldTouchedConfig Configuration interface for checking whether a specific field is touched. Used by the `isTouched` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `IsFieldTouchedConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`isTouched`](/methods/api/isTouched.md) ### IsFieldValidConfig Configuration interface for checking whether a specific field is valid. Used by the `isValid` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `IsFieldValidConfig` - `path` `ValidPath, TFieldPath>` #### Related ##### Methods [`isValid`](/methods/api/isValid.md) ### IsFormDirtyConfig Configuration interface for checking whether the entire form is dirty. Used by the `isDirty` method when no specific field path is provided. #### Definition - `IsFormDirtyConfig` - `path` `undefined = undefined` #### Related ##### Methods [`isDirty`](/methods/api/isDirty.md) ### IsFormEditedConfig Configuration interface for checking whether the entire form is edited. Used by the `isEdited` method when no specific field path is provided. #### Definition - `IsFormEditedConfig` - `path` `undefined = undefined` #### Related ##### Methods [`isEdited`](/methods/api/isEdited.md) ### IsFormTouchedConfig Configuration interface for checking whether the entire form is touched. Used by the `isTouched` method when no specific field path is provided. #### Definition - `IsFormTouchedConfig` - `path` `undefined = undefined` #### Related ##### Methods [`isTouched`](/methods/api/isTouched.md) ### IsFormValidConfig Configuration interface for checking whether the entire form is valid. Used by the `isValid` method when no specific field path is provided. #### Definition - `IsFormValidConfig` - `path` `undefined = undefined` #### Related ##### Methods [`isValid`](/methods/api/isValid.md) ### MaybeGetter A type that can be either a value or a getter function that returns that value. #### Generics - `TValue` `extends unknown` #### Definition - `MaybeGetter` `TValue | (() => TValue)` ### MoveConfig Configuration interface for moving items within array fields. Used by the `move` method. #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Definition - `MoveConfig` - `path` `ValidArrayPath, TFieldArrayPath>` - `from` `number` - `to` `number` #### Related ##### Methods [`move`](/methods/api/move.md) ### PartialValues Utility type that recursively makes all value properties optional, including nested objects and arrays. #### Generics - `TValue` `extends unknown` #### Definition > This type is too complex to display. Please refer to the [source code](https://github.com/open-circle/formisch/blob/main/packages/core/src/types/utils/utils.ts). #### Related ##### Methods [`getInput`](/methods/api/getInput.md) ### Path Type definition for readonly arrays of path keys used to access nested properties. #### Definition - `Path` `ReadonlyArray` ### PathKey Type definition for keys used in paths to access nested properties in objects and arrays. #### Definition - `PathKey` `string | number` ### PathValue Conditional type that extracts the value type at the given path. #### Generics - `TValue` `extends unknown` - `TPath` `extends Path` #### Definition - `PathValue` `PathValue` #### Related ##### Methods [`getInput`](/methods/api/getInput.md), [`insert`](/methods/api/insert.md), [`replace`](/methods/api/replace.md), [`reset`](/methods/api/reset.md), [`setInput`](/methods/api/setInput.md) ### PickDirtyConfig Configuration interface for picking dirty parts of a value. Used by the `pickDirty` method. #### Generics - `TValue` `extends object` #### Definition - `PickDirtyConfig` - `from` `TValue` #### Related ##### Methods [`pickDirty`](/methods/api/pickDirty.md) ### RemoveConfig Configuration interface for removing items from array fields. Used by the `remove` method. #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Definition - `RemoveConfig` - `path` `ValidArrayPath, TFieldArrayPath>` - `at` `number` #### Related ##### Methods [`remove`](/methods/api/remove.md) ### ReplaceConfig Configuration interface for replacing items in array fields. Used by the `replace` method. #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Definition - `ReplaceConfig` - `path` `ValidArrayPath, TFieldArrayPath>` - `at` `number` - `initialInput` `DeepPartial, [...TFieldArrayPath, number]>> | undefined` #### Related ##### Methods [`replace`](/methods/api/replace.md) ### RequiredPath A type that represents a required path into an object structure with at least one key. #### Definition - `RequiredPath` `readonly [PathKey, ...Path]` #### Related ##### Methods [`focus`](/methods/api/focus.md), [`getErrors`](/methods/api/getErrors.md), [`getInput`](/methods/api/getInput.md), [`replace`](/methods/api/replace.md), [`setInput`](/methods/api/setInput.md), [`swap`](/methods/api/swap.md) ### ResetFieldConfig Configuration interface for resetting field-specific input and errors. Used by the `reset` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `ResetFieldConfig` - `path` `ValidPath, TFieldPath>` - `initialInput` `DeepPartial, TFieldPath>> = undefined` - `keepEdited` `boolean = false` - `keepErrors` `boolean = false` - `keepInput` `boolean = false` - `keepTouched` `boolean = false` #### Related ##### Methods [`reset`](/methods/api/reset.md) ### ResetFormConfig Configuration interface for resetting form input and errors. Used by the `reset` method when no specific field path is provided. #### Generics - `TSchema` `extends FormSchema` #### Definition - `ResetFormConfig` - `path` `undefined = undefined` - `initialInput` `DeepPartial> = undefined` - `keepEdited` `boolean = false` - `keepErrors` `boolean = false` - `keepInput` `boolean = false` - `keepSubmitted` `boolean = false` - `keepTouched` `boolean = false` #### Related ##### Methods [`reset`](/methods/api/reset.md) ### Schema Schema type definition that represents any Valibot schema that can be used with Formisch. #### Definition - `Schema` `GenericSchema | GenericSchemaAsync` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`validate`](/methods/api/validate.md) ### SetFieldErrorsConfig Configuration interface for setting field-specific errors. Used by the `setErrors` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `SetFieldErrorsConfig` - `path` `ValidPath, TFieldPath>` - `errors` `[string, ...string[]] | null` #### Related ##### Methods [`setErrors`](/methods/api/setErrors.md) ### SetFieldInputConfig Configuration interface for setting field-specific input. Used by the `setInput` method when a specific field path is provided. #### Generics - `TSchema` `extends FormSchema` - `TFieldPath` `extends RequiredPath` #### Definition - `SetFieldInputConfig` - `path` `ValidPath, TFieldPath>` - `input` `PathValue, TFieldPath>` #### Related ##### Methods [`setInput`](/methods/api/setInput.md) ### SetFormErrorsConfig Configuration interface for setting form-level errors. Used by the `setErrors` method when no specific field path is provided. #### Definition - `SetFormErrorsConfig` - `path` `undefined = undefined` - `errors` `[string, ...string[]] | null` #### Related ##### Methods [`setErrors`](/methods/api/setErrors.md) ### SetFormInputConfig Configuration interface for setting form-level input. Used by the `setInput` method when no specific field path is provided. #### Generics - `TSchema` `extends FormSchema` #### Definition - `SetFormInputConfig` - `path` `undefined = undefined` - `input` `v.InferInput` #### Related ##### Methods [`setInput`](/methods/api/setInput.md) ### SubmitEventHandler Function type for handling form submission with the submit event. Used by the `handleSubmit` method and form components. #### Generics - `TSchema` `extends FormSchema` #### Parameters - `output` `InferOutput` - `event` `SubmitEvent` #### Related ##### Methods [`handleSubmit`](/methods/api/handleSubmit.md) ##### Types [`SubmitHandler`](/core/api/SubmitHandler.md) ### SubmitHandler Function type for handling form submission without the submit event. Used by the `handleSubmit` method. #### Generics - `TSchema` `extends FormSchema` #### Parameters - `output` `InferOutput` #### Related ##### Methods [`handleSubmit`](/methods/api/handleSubmit.md) ##### Types [`SubmitEventHandler`](/core/api/SubmitEventHandler.md) ### SwapConfig Configuration interface for swapping items in array fields. Used by the `swap` method. #### Generics - `TSchema` `extends FormSchema` - `TFieldArrayPath` `extends RequiredPath` #### Definition - `SwapConfig` - `path` `ValidArrayPath, TFieldArrayPath>` - `at` `number` - `and` `number` #### Related ##### Methods [`swap`](/methods/api/swap.md) ### UseFieldArrayConfig Configuration object for creating a field array store with [`useFieldArray`](/svelte/api/useFieldArray.md). #### Generics - `TSchema` `extends FormSchema = FormSchema` - `TFieldArrayPath` `extends RequiredPath = RequiredPath` #### Definition - `UseFieldArrayConfig` - `path` `ValidArrayPath, TFieldArrayPath>` ### UseFieldConfig Configuration object for creating a field store with [`useField`](/svelte/api/useField.md). #### Generics - `TSchema` `extends FormSchema = FormSchema` - `TFieldPath` `extends RequiredPath = RequiredPath` #### Definition - `UseFieldConfig` - `path` `ValidPath, TFieldPath>` ### ValidArrayPath A utility type that validates array paths and returns the first possible valid array path based on the given value if the provided path is invalid. #### Generics - `TValue` `extends unknown` - `TPath` `extends RequiredPath` > This type is too complex to display. Please refer to the [source code](https://github.com/open-circle/formisch/blob/main/packages/core/src/types/path/path.ts). ### ValidateFormConfig Configuration interface for form validation. Used by the `validate` method to specify validation behavior. #### Definition - `ValidateFormConfig` - `shouldFocus` `boolean = false` #### Related ##### Methods [`validate`](/methods/api/validate.md) ### ValidationMode Validation mode type that defines when and how form validation is triggered. #### Definition - `ValidationMode` `'initial' | 'touch' | 'input' | 'change' | 'blur' | 'submit'` #### Related ##### Primitives [`useForm`](/react/api/useForm.md) ##### Methods [`validate`](/methods/api/validate.md) ### ValidPath Conditional type that returns the path if valid, otherwise the first possible valid path based on the given value. #### Generics - `TValue` `extends unknown` - `TPath` `extends RequiredPath` #### Definition - `ValidPath` `TPath extends LazyPath, TPath> ? TPath : LazyPath, TPath>` #### Related ##### Methods [`focus`](/methods/api/focus.md), [`getErrors`](/methods/api/getErrors.md), [`getInput`](/methods/api/getInput.md), [`reset`](/methods/api/reset.md), [`setErrors`](/methods/api/setErrors.md), [`setInput`](/methods/api/setInput.md)