Form errors
Manipulate form errors with use-form
Source
Docs
Package
Errors object
form.errors is an object of React nodes that contains validation errors:
Initial errors
Same as with initial values you can set initial form errors:
setErrors handler
setFieldError handler
form.setFieldError handler sets error of the given field:
clearErrors handler
form.clearErrors handler clear all form errors:
clearFieldError handler
form.clearFieldError handler clears error of the given field:
Errors as react node
You can use any React node as an error message:
Note that errors that are false, null or undefined will be automatically removed:
FormErrors type
form.errors type is Record<string, React.ReactNode>, you can import a shorthand FormErrors type from @mantine/form:
You can also get type directly from the form instance: