feat(forms): migrate all forms to React Hook Form + Zod (#509)#649
Merged
Hydrax117 merged 1 commit intoJun 30, 2026
Conversation
…g#509) - Add react-hook-form and @hookform/resolvers to package.json - Add Form UI primitives (FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage) - Add Zod schemas: auth, profile, contact, wallet, tournament - Migrate 9 forms: LoginForm, RegisterForm, PasswordResetForm, ContactForm, ProfileBio, profile/edit, AccountSettings, WithdrawModal, RegistrationForm - Add useFormAnalytics hook (Datadog RUM integration) - Add form testing utilities and schema unit tests - Add FORM_VALIDATION.md documentation - Remove .kiro/ from git tracking (already in .gitignore)
|
@peace-cyber09 is attempting to deploy a commit to the paul joseph's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@peace-cyber09 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhances form validation across the frontend by migrating all forms to React Hook Form with Zod schemas, replacing inconsistent manual validation with a unified, type-safe, and accessible pattern.
Type of change
Related issues
Closes #509
Changes
Infrastructure
react-hook-form@^7.53.0and@hookform/resolvers@^3.9.0topackage.jsonsrc/components/ui/Form.tsx— composable RHF primitives (Form,FormField,FormItem,FormLabel,FormControl,FormDescription,FormMessage) with auto-wiredaria-invalid,aria-describedby,htmlFor, androle="alert"on error messagessrc/lib/validations/index.ts— central re-export for all schemassrc/hooks/useFormAnalytics.ts— tracks form start, submit (success/fail), per-field errors, and abandons; integrates with Datadog RUM in production, console in devsrc/lib/testing/formTestUtils.tsx— reusable test helpers (renderForm,fillField,submitForm,expectFieldError,testSchema)FORM_VALIDATION.md— full documentation covering the stack, schema catalogue, validation modes, error handling patterns, accessibility, testing guide, and how to add new formsZod schemas
src/lib/validations/auth.ts—loginSchema,registerSchema(existing, expanded withagreeToTerms),passwordResetRequestSchema,passwordResetSchema,accountSettingsSchema(withsuperRefinefor conditional password-change validation)src/lib/validations/profile.ts—profileBioSchema(existing, unchanged),profileEditSchema(new, covers username + bio + 4 social link URLs)src/lib/validations/contact.ts—contactSchemasrc/lib/validations/wallet.ts—withdrawSchema(Stellar address regex, balance checks deferred to submit handler),depositSchemasrc/lib/validations/tournament.ts—tournamentRegistrationSchemasrc/lib/validations/__tests__/schemas.test.ts— 40+ unit tests covering valid and invalid cases for all 8 schemasMigrated forms (9 total)
All forms now use
useForm+zodResolver+<FormField>primitives. ManualuseStatevalidation state, ad-hoc regex checks, andvalidate()functions removed throughout.LoginFormloginSchema; auth context error banner preserved; analytics wiredRegisterFormonTouchedmode; async username availability piped intoform.setError; field-specific server errors fromREGISTER_ERROR_MAPviaform.setErrorPasswordResetFormuseForminstances for request and reset steps;form.setError('root')for API errorsContactFormcontactSchema; success state driven byisSubmitSuccessful; root error for submission failuresProfileBioisEditingoptional — backwards-compatible with existing call sites); RHF replaces manual bio/social link stateprofile/edit/page.tsxisDirtyreplacing manual unsaved-changes tracking; async username check wired toform.setError; avatar error stays local (file input, not a schema field)AccountSettingsaccountSettingsSchema; validated data synced back touseSettingsstore on submit; server-side field errors fed back viaform.setErrorWithdrawModalwithdrawSchemahandles format/format validation; runtime balance checks remain in submit handler and setform.setError; modal reset viauseEffectonopenRegistrationFormtournamentRegistrationSchema;isSubmitSuccessfuldrives success state; API error viaform.setError('root')Accessibility improvements
<FormControl>wrappers automatically applyaria-invalidandaria-describedbylinking to both description and error message ids<FormMessage>elements render withrole="alert"andaria-live="polite"aria-labelattributes<form>elements usenoValidateto suppress native browser validation bubblesrole="alert"consistentlyTesting
npm test)cargo testincontracts/)Schema tests
Checklist
.down.sqlexists) — N/A (frontend only)