Vest v1.0.0 Release Notes

Release Date: 2019-12-22 // over 4 years ago
  • Vest

    โœ… Vest - Validation Testing

    ๐Ÿ— npm version Build Status

    What is Vest?

    Vest is a validations library for JS apps that derives its syntax from modern JS frameworks such as Mocha or Jest. It is easy to learn due to its use of already common declarative patterns.

    The idea behind Vest is that your validations can be described as a 'spec' or a contract that reflects your form or feature structure. Your validations run in production, and they are framework agnostic - meaning Vest works well with React, Angular, Vue, or even without a framework at all.

    Example code:

    // validation.jsimport { validate, test, enforce } from 'vest';const validation = (data) =\> validate('NewUserForm', () =\> {test('username', 'Must be at least 3 chars', () =\> {enforce(data.username).longerThanOrEquals(3);});test('email', 'Is not a valid email address', () =\> {enforce(data.email).isNotEmpty().matches(/[^@]+@[^\.]+\..+/g);});});export default validation;
    
    // myFeature.jsimport validation from './validation.js';const res = validation({username: 'example',email: '[email protected]'});res.hasErrors() // returns whether the form has errorsres.hasErrors('username') // returns whether the 'username' field has errorsres.getErrors() // returns an object with an array of errors per fieldres.getErrors('username') // returns an array of errors for the `username` field
    

    Why Vest?

    • โœ… Vest is really easy to learn, and you can easily take your existing knowledge of unit tests and transfer it to validations.
    • Vest takes into account user interaction and warn only validations.
    • Your validations are structured, making it very easy to read and write. All validation files look the same.
    • Your validation logic is separate from your feature logic, preventing the spaghetti code that's usually involved with writing validations.
    • Validation logic is easy to share and reuse across features.
    • If your backend is node, you can use the same Vest modules for both client-side and server-side validations.

    Vest is a continuation of Passable by Fiverr.