mapValidationErrors
Call Signature
Section titled “Call Signature”mapValidationErrors(
error,options?):FieldErrors
Defined in: react/src/validation.ts:74
Maps validation error issues to a simple field -> message object.
Returns the first error message for each field path, or every message with
{ multiple: true }. Issues about the whole argument (an empty path) are
filed under "".
Parameters
Section titled “Parameters”options?
Section titled “options?”multiple?
Section titled “multiple?”false
Returns
Section titled “Returns”Example
Section titled “Example”const { mutate } = useActorMutation({ functionName: "transfer", onError: (error) => { if (isValidationError(error)) { const fieldErrors = mapValidationErrors(error) // { to: "Recipient is required", amount: "Must be a number" }
// Use with React Hook Form Object.entries(fieldErrors).forEach(([field, message]) => { form.setError(field, { message }) }) } }})Call Signature
Section titled “Call Signature”mapValidationErrors(
error,options):FieldErrorsMultiple
Defined in: react/src/validation.ts:78
Maps validation error issues to a simple field -> message object.
Returns the first error message for each field path, or every message with
{ multiple: true }. Issues about the whole argument (an empty path) are
filed under "".
Parameters
Section titled “Parameters”options
Section titled “options”multiple
Section titled “multiple”true
Returns
Section titled “Returns”Example
Section titled “Example”const { mutate } = useActorMutation({ functionName: "transfer", onError: (error) => { if (isValidationError(error)) { const fieldErrors = mapValidationErrors(error) // { to: "Recipient is required", amount: "Must be a number" }
// Use with React Hook Form Object.entries(fieldErrors).forEach(([field, message]) => { form.setError(field, { message }) }) } }})Call Signature
Section titled “Call Signature”mapValidationErrors(
error,options?):FieldErrors|FieldErrorsMultiple
Defined in: react/src/validation.ts:82
Maps validation error issues to a simple field -> message object.
Returns the first error message for each field path, or every message with
{ multiple: true }. Issues about the whole argument (an empty path) are
filed under "".
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”FieldErrors | FieldErrorsMultiple
Example
Section titled “Example”const { mutate } = useActorMutation({ functionName: "transfer", onError: (error) => { if (isValidationError(error)) { const fieldErrors = mapValidationErrors(error) // { to: "Recipient is required", amount: "Must be a number" }
// Use with React Hook Form Object.entries(fieldErrors).forEach(([field, message]) => { form.setError(field, { message }) }) } }})