Let's just take a look at the current validation landscape, and it can get quite overwhelming. If you look at this npm search result, it says there's over 1,000 packages related to form validation, and this is just the way that npm displays results. There's over 10,000 packages related to form validation. And this tells us two things. One is that form validation is a widespread challenge, the other one, there's no single solution that fits all the needs. There are different validation approaches out there, but probably the most used are schema validation packages and framework validation packages. The first are great for server-side validation and data structures, but they feel a little, I don't know, disconnected from the user experience, since users don't really type into a schema.
The second one, framework-specific, they are great, but they can sometimes feel overly opionated, and they always vendor lock you into some framework or into some pattern. What developers really need is something that's flexible, reusable, and maintainable that can handle complex scenarios without sacrificing developer experience or performance. Let's take a look at VEST. VEST was created by Avatar and takes a new and fresh approach to solving some of these challenges. It was inspired by unit testing frameworks and brings those familiar patterns to validation. It's easy to learn, especially if you have used it just before. It's framework agnostic, smart, powerful features, and performance optimizations out of the box. It's fully reusable across client and server environments, solving the classical duplicate validation problem.
And now I will play a short video that shows the striking similarity between Jest test code and VEST validation code. So we start with Jest, where we use terms like describe, groups, tests, and expect that checks results. Then moving to VEST, describe turns into VEST create, you will see it in the end of the video, and expect becomes enforce, which applies validation rules. VEST also takes an extra parameter in each validation, which is the field name to validate. And of course, the whole validation suit gets the form data to validate. This structure is very similar to Jest, just with a few new details, making the switch easy to understand. And this familiar approach means that we can get up to speed quickly, and our validation logic becomes clear and maintainable.
Comments