Skip to content

feat: integrate react-hook-form and zod across all forms#271

Open
OTimileyin wants to merge 1 commit into
Nexacore-Org:v2from
OTimileyin:feat/rhf-zod-forms
Open

feat: integrate react-hook-form and zod across all forms#271
OTimileyin wants to merge 1 commit into
Nexacore-Org:v2from
OTimileyin:feat/rhf-zod-forms

Conversation

@OTimileyin

@OTimileyin OTimileyin commented Jun 25, 2026

Copy link
Copy Markdown

Closes #247

Summary

  • Replaces all ad-hoc useState validation logic with react-hook-form + zod across all 8 forms
  • Introduces a shared components/ui/Input component with error prop + forwarded ref, used consistently across all forms
  • All validation schemas live in lib/validations/ with exported TypeScript types

Forms migrated

# Form Path
1 Login app/(auth)/login/page.tsx
2 Signup app/(auth)/signup/page.tsx
3 Forgot Password app/(auth)/forgot-password/page.tsx
4 Reset Password app/(auth)/reset-password/page.tsx
5 Convert components/dashboard/convert/convert-form.tsx
6 Withdrawal components/dashboard/withdrawal/WithdrawalForm.tsx
7 Settings Profile components/profile/profile-edit-form.tsx
8 Admin Push Notification components/admin/push-notifications/CreatePushNotificationModal.tsx

Shared schema approach

Schemas in lib/validations/:

  • auth.ts — login, signup, forgot-password, reset-password
  • transactions.ts — convert, withdrawal
  • profile.ts — settings profile
  • notifications.ts — admin push notification

Each schema exports inferred TypeScript types used as useForm<T> generics.

Validation pattern

Every form uses useForm({ resolver: zodResolver(schema) }). Field errors are passed to the Input component's error prop, which renders the message inline below each field. Input uses React.forwardRef so RHF's register() can attach refs correctly.

Notable: Reset Password OTP

The OTP field preserves the 6-digit custom input UX (individual boxes + auto-focus). A hidden <input type="hidden"> is registered with RHF and synced via setValue("otp", digits.join("")) as digits change, so zodResolver validates the joined 6-digit string against z.string().length(6).

No ad-hoc validation remains

Confirmed via grep — zero occurrences of useState.*errors, setErrors, validateForm(), or inline regex guards across all 8 forms.

Verification

  • npm run build ✅ — TypeScript + compile, 0 errors
  • npm run lint ✅ — 0 errors (2 React Compiler watch() warnings are an expected known limitation with RHF)

This PR targets v2, not main.

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@OTimileyin is attempting to deploy a commit to the Emmanuel Dorcas' projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 25, 2026

Copy link
Copy Markdown

@OTimileyin 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! 🚀

Learn more about application limits

@portableDD

Copy link
Copy Markdown
Contributor

@OTimileyin please esolve conflivts

@OTimileyin OTimileyin force-pushed the feat/rhf-zod-forms branch from 174eaa0 to 5c80b99 Compare June 26, 2026 21:26
@portableDD

Copy link
Copy Markdown
Contributor

This PR has merge conflicts. Please rebase on latest v2 and fix the conflicts.

3 similar comments
@portableDD

Copy link
Copy Markdown
Contributor

This PR has merge conflicts. Please rebase on latest v2 and fix the conflicts.

@portableDD

Copy link
Copy Markdown
Contributor

This PR has merge conflicts. Please rebase on latest v2 and fix the conflicts.

@portableDD

Copy link
Copy Markdown
Contributor

This PR has merge conflicts. Please rebase on latest v2 and fix the conflicts.

@portableDD

Copy link
Copy Markdown
Contributor

This PR has extensive merge conflicts with v2. Please rebase your branch on the latest v2 and resolve the conflicts so it can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants