Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

UseFormSetError

Set an error for the field. When set an error which is not associated to a field then manual clearErrors invoke is required.

@example
// when the error is not associated with any fields, `clearError` will need to invoke to clear the error
const onSubmit = () => setError("serverError", { type: "server", message: "Error occurred"})

<button onClick={() => setError("name", { type: "min" })} />

// focus on the input after setting the error
<button onClick={() => setError("name", { type: "max" }, { shouldFocus: true })} />
type UseFormSetError<TFieldValues extends FieldValues> = (
name: FieldPath<TFieldValues> | `root.${string}` | "root",
error: ErrorOption,
options?: {
shouldFocus: boolean;
}
,
) => void
;

§Type Parameters

§
TFieldValues extends FieldValues
[src]

§Type

§
(name: FieldPath<TFieldValues> | `root.${string}` | "root", error: ErrorOption, options?: {
shouldFocus: boolean;
}
) => void
[src]