Function useFormErrors

  • Hook used to gain access to errors of all invalid form fields. Causes the component to subscribe to changes of all field errors.

    Type Parameters

    • Values extends object

    • Err

    Parameters

    • _Schema: FormSchema<Values, Err>
    • Optional controller: FormController

      obtained by using useFormController hook, used to connect to form state. Injected automatically via React Context when used inside FormProvider component.

    Returns FieldError<Err>[]

    array of all field errors represented as FieldError objects. Each object contains field ID and it's error.

    Example

    const Schema = new FormSchemaBuilder()...;

    const MyForm: React.FC = () => {
    const controller = useFormController({ Schema })
    const errors = useFormErrors(Schema, controller)

    ...
    }

Generated using TypeDoc