Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/netzo/deps/react-hook-form.ts>UseFormSetError

Full-stack Deno framework for building business web apps like internal tools, dashboards, admin panels and automated workflows.
Go to Latest
type alias UseFormSetError
import { type UseFormSetError } from "https://deno.land/x/netzo@0.4.62/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

// 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: (
name: FieldPath<TFieldValues> | `root.${string}` | "root",
error: ErrorOption,
options?: { shouldFocus: boolean; },
) => void