Interface UseFormOptions<T>

Options for the useForm hook

Type Parameters

  • T

    The type of the form state.

Hierarchy

  • UseFormOptions

Properties

autoValidateBehavior?: "never" | "onBlur" | "onChange" | "immediate"

Decide when to auto validate the form. Defaults to onChange.

immediate - Show validation errors as soon as the hook mounts, as well as onChange and onBlur.

onChange - Show validations after the user has changed the input.

onBlur - Show validations after the user has blurred the input.

never - Show validations after the user has submitted the form only, or on manual trigger.

See

validate for manual validation trigger

errorMessages?: Partial<ErrorStrings>

Map of custom error messages for the default validation methods.

See

initialState?: Partial<T>

The initial state of the form. This will cause the form inputs to be pre-filled with the given data. Any missing field will be empty.

Methods

  • Callback that will be fired when the form is submitted. The callback will receive the form data.

    Parameters

    • values: T
    • e: FormEvent<HTMLFormElement>

    Returns void

Generated using TypeDoc