Refactor: Standardize Form Validation & UI with react-hook-form + Zod
Overview
Form handling across the app (bounty creation, application, profile) is currently inconsistent in terms of validation, structure, and UI.
To improve consistency and developer experience, we should introduce a reusable form field wrapper built with react-hook-form and zod, ensuring uniform validation, error handling, and UI across all forms.
Goals
- Standardize form validation using Zod
- Unify form UI (labels, errors, descriptions)
- Reduce duplication in form logic
- Improve developer experience and maintainability
Implementation Details
1. Create Reusable Form Wrapper
Create: components/ui/form-field-wrapper.tsx
- Build a reusable component that:
- Integrates with
react-hook-form
- Accepts field props (name, control, etc.)
- Renders:
- Label
- Input (via children or render prop)
- Error message
- Description/help text
- Ensure compatibility with Zod validation schema
- Support different input types (input, textarea, select, etc.)
2. Refactor Existing Forms
components/bounty/forms/milestone-builder.tsx
- Replace custom input handling with the new wrapper
- Ensure all fields use consistent validation and error display
components/bounty/application-dialog.tsx
- Refactor input handling to use the wrapper
- Remove duplicated validation/UI logic
- Ensure proper integration with
react-hook-form and Zod schema
Files Affected
Modified
components/bounty/forms/milestone-builder.tsx
components/bounty/application-dialog.tsx
Created
components/ui/form-field-wrapper.tsx
Acceptance Criteria
Testing Notes
- Validate form submission with valid and invalid inputs
- Ensure error messages appear correctly for all fields
- Test different input types (text, textarea, select, etc.)
- Confirm no regression in form behavior or UX
Additional Notes
- Consider extending wrapper to support custom components (e.g., date pickers)
- Keep the wrapper flexible but opinionated for consistency
- Co-locate Zod schemas with form components where appropriate
- Optionally integrate with a UI library (e.g., shadcn/ui) for styling consistency
Refactor: Standardize Form Validation & UI with react-hook-form + Zod
Overview
Form handling across the app (bounty creation, application, profile) is currently inconsistent in terms of validation, structure, and UI.
To improve consistency and developer experience, we should introduce a reusable form field wrapper built with
react-hook-formandzod, ensuring uniform validation, error handling, and UI across all forms.Goals
Implementation Details
1. Create Reusable Form Wrapper
Create:
components/ui/form-field-wrapper.tsxreact-hook-form2. Refactor Existing Forms
components/bounty/forms/milestone-builder.tsxcomponents/bounty/application-dialog.tsxreact-hook-formand Zod schemaFiles Affected
Modified
components/bounty/forms/milestone-builder.tsxcomponents/bounty/application-dialog.tsxCreated
components/ui/form-field-wrapper.tsxAcceptance Criteria
Testing Notes
Additional Notes