onError()
This event handler runs when the form runs into a validation error.
Overview
onError
is a <Feathery.Form> prop and callback function to access and modify form state when an error has occurred in the form.
For example, it's triggered when an integration fails or when the user fills out invalid information. If an error is manually set via the React library, this callback will not be triggered. This function can be asynchronous.
Usage
You can use onError
to navigate to a new step, update field values, and more. The function takes a single Context object that provides form-related state and handlers.
Context API
Key | Type | Description |
---|---|---|
Consistently available form state and functions | ||
|
| The ID of the field that is erroring. |
|
| The type of the field that is erroring. |
|
| The error message. |
| The info of the error trigger. |
triggerData
Definition
triggerData
DefinitionKey | Type | Description |
---|---|---|
|
| The ID of the element that triggered the error. |
|
| The text displayed on the element that triggered the error. |
|
| The type of element that triggered the error. Can be |
|
| If the element that errored repeats, this specifies which repetition it is. This value is 0-indexed and equals 0 if the element doesn't repeat. |
Return value
A promise can be optionally returned from this function if it's asynchronous and you want execution to await.
Last updated