Type-Safe Form Validation Library
Build a small, reusable form-validation library with a fluent API for chaining rules like required, minLength, and custom validators, fully typed with generics so validation errors are inferred per field. Learners practice advanced TypeScript generics, conditional types, and API design for libraries.
- Estimate
- ~10h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Vitest · tsup
Project roadmap
- 01
Design the fluent API surface
~1.5hSketch the chainable validator API, e.g. field('name').required().minLength(3).
- 02
Implement core validators
~2hImplement required, minLength, maxLength, and pattern validators.
- 03
Add generic type inference for errors
~2.5hUse TypeScript generics so validation error shapes are inferred per field type.
- 04
Support custom validators
~1.5hAllow consumers to plug in their own validation functions with full type safety.
- 05
Write unit tests
~1.5hCover common rules and edge cases with Vitest.
- 06
Configure the build
~1hSet up tsup to produce a publishable library bundle with type declarations.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack