DEV Community

Mayuresh Pandit
Mayuresh Pandit

Posted on

Why I Built a Lightweight Form Validation Library for Modern Web Apps

Hey everyone! đź‘‹

When working on modern JavaScript and TypeScript applications—especially when integrating with frameworks like Angular—handling form validation is a daily task. However, I often found myself wanting a clean, straightforward solution without bringing in heavy, bloated dependencies.


To solve this, I decided to build and publish my own open-source package from scratch: universal-form-validator.

What it does:
Zero Dependencies: Keeps your project bundle lightweight and fast.

Flexible Schemas: Easily handles common validation requirements like strings, strict numbers, emails, dates, and passwords.

Framework Friendly: Tested and structured to plug smoothly into modern workflows.

If you are looking for a clean, minimalist validation engine for your next project, you can check out the repository or install it directly via npm:

npm:

npm i universal-form-validator

GitHub: universal-form-validator

I built this to solve a specific workflow problem, and I'd love to hear your thoughts or feedback if you try it out. Happy coding! 🚀

Top comments (3)

Collapse
 
topstar_ai profile image
Luis Cruz

I was particularly drawn to the "Zero Dependencies" aspect of universal-form-validator, as I've often found myself grappling with the trade-off between feature-rich libraries and bundle size. By keeping the library lightweight, you've addressed a common pain point for many developers. I'm curious to know more about how you handled complex validation scenarios, such as conditional logic or nested object validation, within the library - were there any specific design decisions or challenges that arose during implementation?

Collapse
 
dreainno profile image
Mayuresh Pandit

Hey Liz! Thanks for checking it out and raising such a great point.

When designing universal-form-validator, keeping the bundle size at zero dependencies meant avoiding heavy recursive parsers right out of the gate. For nested objects, the validation engine uses a modular schema traversal approach where key-value pairs map down recursively only when a nested schema definition is provided.

As for conditional logic, rather than baking complex state machines into the core library (which bloats size), the design relies on custom rule parsers and evaluators that let you pass dynamic conditions or skip rules based on field states.

If you dive into the codebase or test it out with deeply nested forms, I'd love to hear your thoughts on how the traversal holds up or if you run into any edge cases!

Collapse
 
topstar_ai profile image
Luis Cruz

That modular traversal approach makes a lot of sense for keeping the core lightweight. I especially like the decision to keep conditional logic outside the core rather than turning the validator into a large rules engine.

One area I’d be curious to explore is how this could evolve for production SaaS applications — things like async validation, reusable schema composition, API/backend validation, and consistent validation rules across frontend and backend without sacrificing the zero-dependency philosophy.

I work on full-stack and AI/backend systems, and I’m always interested in collaborating with developers building focused, practical open-source tools like this. If you’re open to collaboration, paid engineering work, or have a related project where you need another developer, feel free to connect. I’d be happy to exchange ideas and see if there’s a good fit.