forms-validation
How forms validate input in this template — Zod schema at the boundary, accessible error messaging, and the submit-validate-report pattern.
SKILL.md.claude/skills/forms-validation/SKILL.md
GitHub- Every form has a Zod schema in
src/lib/schemas.tsthat is the single source of truth for validity — the same schema is used for the client-side check on submit AND inside the mutation'smutationFn(server-state-tanstack-queryskill) so the two can never disagree. - Validate on submit with
schema.safeParse(...), not on every keystroke, unless the spec's EARS criteria explicitly call for inline/live validation — seeSubscribeDialog.tsxfor the submit-time pattern. - Error messages: one
<p role="alert" id="<field>-error">per invalid field, and the input carriesaria-invalid+aria-describedbypointing at that id (see the email input inSubscribeDialog.tsx) — a validation error that isn't announced to assistive tech is an a11y bug, not just a UX one, anda11y-auditorwill flag it. - Never trust
zod's error message text verbatim for user-facing copy without checking it reads naturally — write an explicitmessagein the schema (z.string().email("Enter a valid email address")) rather than relying on the default. - Disable the submit control while the mutation is pending (
mutation.isPending) and label it accordingly ("Subscribing..." not just a spinner with no text) so screen reader users get the same feedback sighted users do.