Vest

Vest Declarative validations framework

README

Vest - Declarative validations framework


Join Discord Github Stars Version Downloads bundlephobia Status

Vest

Vest is a form-validation framework inspired by unit testing libraries like Mocha or Jest; It is designed to be easy to use and easy to learn by introducing their declarative syntax.

The idea behind Vest is that your validations can be described as a suite - a contract that reflects your form or feature structure. Vest is framework agnostic, meaning it can be used with any UI framework, or without any framework at all.

Using Vest for form validation can reduce bloat, improve feature readability and maintainability.

  1. ``` js
  2. test('username', 'Username is required', () => {
  3.   enforce(data.username).isNotBlank();
  4. });

  5. test('username', 'Username must be at least 3 chars', () => {
  6.   enforce(data.username).longerThanOrEquals(3);
  7. });

  8. test('username', 'Username already taken', async () => {
  9.   await doesUserExist(data.username);
  10. });
  11. ```

Installation


  1. ```
  2. npm i vest
  3. ```

Motivation


Writing forms is an integral part of building web apps, and even though it may seem trivial at first - as your feature grows over time, so does your validation logic grows in complexity.

Vest tries to remediate this by separating validation logic from feature logic, so it's easier to maintain over time and refactor when needed.

Why Vest?


💡 Vest is easy to Learn. Vest adopts the syntax and style of unit testing frameworks, so you can leverage the knowledge you already have to write your form validations.

🎨 Vest is framework agnostic. You can use Vest with any UI framework out there.

🧠 Vest takes care of all the annoying parts for you. It manages its validation state, handles async validations, and much more.

🧩 Vest is extendable. You can easily add new kinds of validations to Vest according to your needs.

♻️ Validation logic in Vest can be shared across multiple features in your app.

Getting Started



Here are some code sandboxes to get you started:

- Vue

Contribute


Information describing how to contribute can be found here:

https://github.com/ealush/vest/blob/latest/CONTRIBUTING.md