import { type UseFormSetError } from "https://deno.land/x/netzo@0.4.72/deps/react-hook-form.ts";
Set an error for the field. When set an error which is not associated to a field then manual clearErrors
invoke is required.
Examples
Example 1
Example 1
// 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 Parameters
TFieldValues extends FieldValues
definition: () => void
name: FieldPath<TFieldValues> | `root.${string}` | "root",
error: ErrorOption,
options?: { shouldFocus: boolean; },