{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "rhf-rules-02",
  "title": "Email Address",
  "description": "Validate an email address with instant feedback.",
  "dependencies": [
    "react-hook-form",
    "@hookform/resolvers",
    "zod",
    "sonner",
    "lucide-react"
  ],
  "registryDependencies": [
    "card",
    "field",
    "input",
    "button"
  ],
  "files": [
    {
      "path": "registry/forms/react-hook-form/rules/rhf-rules-02.tsx",
      "content": "'use client'\n\nimport { Controller, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { CheckCircle2, Mail } from 'lucide-react'\nimport { toast } from 'sonner'\nimport * as z from 'zod'\n\nimport { Button } from '@/components/ui/button'\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from '@/components/ui/card'\nimport {\n  Field,\n  FieldDescription,\n  FieldError,\n  FieldGroup,\n  FieldLabel,\n} from '@/components/ui/field'\nimport { Input } from '@/components/ui/input'\n\nconst formSchema = z.object({\n  email: z.email('Enter a valid email address.'),\n})\n\ntype FormValues = z.infer<typeof formSchema>\n\nexport function RhfRules02() {\n  const form = useForm<FormValues>({\n    resolver: zodResolver(formSchema),\n    mode: 'onChange',\n    defaultValues: { email: '' },\n  })\n\n  function onSubmit(data: FormValues) {\n    toast.success('Email confirmed', { description: data.email })\n  }\n\n  return (\n    <Card className=\"w-full max-w-sm\">\n      <CardHeader>\n        <CardTitle className=\"flex items-center gap-2\">\n          <Mail className=\"text-muted-foreground size-4\" />\n          Email address\n        </CardTitle>\n        <CardDescription>\n          Enter the email where we can reach you.\n        </CardDescription>\n      </CardHeader>\n      <CardContent>\n        <form onSubmit={form.handleSubmit(onSubmit)}>\n          <FieldGroup>\n            <Controller\n              control={form.control}\n              name=\"email\"\n              render={({ field, fieldState }) => (\n                <Field data-invalid={fieldState.invalid}>\n                  <FieldLabel htmlFor=\"rhf-rules-02-email\">Email</FieldLabel>\n                  <Input\n                    {...field}\n                    id=\"rhf-rules-02-email\"\n                    type=\"email\"\n                    placeholder=\"you@example.com\"\n                    aria-invalid={fieldState.invalid}\n                  />\n                  {fieldState.invalid ? (\n                    <FieldError errors={[fieldState.error]} />\n                  ) : fieldState.isDirty ? (\n                    <FieldDescription className=\"flex items-center gap-1.5 text-emerald-600 dark:text-emerald-500\">\n                      <CheckCircle2 className=\"size-3.5\" />\n                      Looks good.\n                    </FieldDescription>\n                  ) : (\n                    <FieldDescription>\n                      We&apos;ll never share your email.\n                    </FieldDescription>\n                  )}\n                </Field>\n              )}\n            />\n            <Button type=\"submit\" size=\"sm\">\n              Continue\n            </Button>\n          </FieldGroup>\n        </form>\n      </CardContent>\n    </Card>\n  )\n}\n",
      "type": "registry:component",
      "target": "components/flx/forms/react-hook-form/rhf-rules-02.tsx"
    }
  ],
  "type": "registry:block"
}