Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

n4s

ealush118.5kMIT5.0.28TypeScript support: included

Assertion library for form validations

vest, enforce, n4s, validation, assertion, schema validation, form validation, validation library

readme

Vest - Declarative validations framework

Vest

Vest Documentation

Join Discord Github Stars Next Tag Version Downloads bundlephobia Status


Vest is a declarative validations framework designed to simplify the process of writing and maintaining form validations for your web application. Inspired by popular unit testing libraries such as Mocha and Jest, Vest allows developers to describe their validation requirements using a suite-like syntax, separating validation logic from feature logic to create more maintainable and readable code.

Vest's framework-agnostic approach means that it can be used with any UI framework, or without any framework at all. With Vest, you can reduce code bloat, improve feature readability and maintainability, and enhance the user experience of your web application.

test('username', 'Username is required', () => {
  enforce(data.username).isNotBlank();
});

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

test('username', 'Username already taken', async () => {
  await doesUserExist(data.username);
});

Installation

npm i vest

Motivation

Building web applications often involves writing complex forms that require validation. As the complexity of these forms increases, so does the complexity of the validation logic required to ensure data is accurate and complete.

At this point, developers may start to experience issues with code bloat, poor maintainability, and difficulty in managing validation logic across different features of an application. This can lead to bugs, errors, and a poor user experience.

Vest was designed to address these issues by providing a simple, intuitive way to write form validation that is easy to learn, scalable, and extensible. By separating validation logic from feature logic, Vest helps developers create maintainable code that is easy to update, debug, and refactor.

With Vest, developers can reduce the complexity and increase the readability of their code, leading to more efficient development cycles, fewer bugs, and a better user experience overall.

Why Vest?

Writing form validations can be time-consuming and complex, especially as your web application grows and evolves over time. Vest simplifies the process by providing a set of powerful tools that take care of the annoying parts for you, such as managing validation state and handling async validations.

Vest's declarative syntax is also designed to be easy to learn, especially for developers who are already familiar with unit testing frameworks. With Vest, you can leverage your existing knowledge to write effective form validations quickly and easily.

💡 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.

🎨 Framework Agnostic

Vest is framework-agnostic, which means you can use it with any UI framework out there.

🧠 Takes Care of the Annoying Parts

Vest manages its validation state, handles async validations, and much more, so you don't have to.

🧩 Extendable

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

♻️ Reusable Validation Logic

Validation logic in Vest can be shared across multiple features in your app, making it easy to maintain and refactor your codebase.

🧬 Supports Declarative Syntax

Vest's declarative syntax makes it easy to describe your form or feature structure and write clear, concise validations.

🧪 Promotes Testing and Debugging

By separating validation logic from feature logic, Vest makes it easier to test and debug your code, which can save you time and reduce errors.

Getting Started

Vest Documentation

Here are some code sandboxes to get you started:

Contribute

Information describing how to contribute can be found here:

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

changelog

n4s - Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

4.0.0 2021-12-24

  • 7daf6d2 rule(n4s): add isNullish rule, improve isBlank (ealush)
  • ddceca7 patch(n4s): improve partial support (ealush)
  • 0370fc1 n4s: extract non-required modules (ealush)
  • 7baedf2 n4s: use named export in entry (ealush)
  • 780c5b7 types(n4s): Allow adding types for custom matchers (ealush)
  • 149aab3 add(n4s): enforce.condition (ealush)
  • d786b34 fix(n4s): make sure oneOf correctly validates single case (ealush)
  • 49e601a feat(n4s): enforce.compose (ealush)
  • 1dddaf4 patch(n4s): improve types for rule chaining (undefined)
  • b5ce72d feat(n4s): context propagation within enforce (undefined)
  • 32fe8a5 feat(n4s): add shape and loose validations (undefined)
  • 39b92f1 patch: enable enforce in es5 environments (undefined)
  • 75306ff fix(n4s): make enforce compound runners fall back to correct response (ealush)
  • 4751584 fix(n4s): make enforce chaining work (ealush)

3.1.0 - 2021-08-06

Added

  • bf432a1 added(n4s): add custom message support to lazy enforcements (undefined)
  • c093a7f added(n4s): partial rule modifier (undefined)
  • 045bc72 feat(n4s): context propagation within enforce (undefined)
  • 443df9d feat(n4s): optional (undefined)
  • 86172ca feat(n4s): isArrayOf (undefined)
  • f48f38b feat(n4s): add shape and loose validations (undefined)

Fixed and improved

  • fdcf20b genscript (undefined)
  • b12614f chore: cleanup residue (undefined)
  • 4da20b4 chore: remove duplicate types (undefined)
  • c66298d tests(n4s): add paritla tests (undefined)
  • packages/anyone/package.json
  • a8c1e67 patch: add nodejs exports (undefined)
  • 83efb86 patch: remove unused exports (undefined)
  • 9546b9e patch(n4s): improve types for rule chaining (undefined)
  • packages/anyone/package.json
  • 7bab926 patch: simplify proxy test/run assignment (undefined)
  • ed5c903 patch: enable enforce in es5 environments (undefined)
  • 3494de6 chore: reduce complexity, remove all lint errors (undefined)
  • packages/anyone/.npmignore
  • .github/PULL_REQUEST_TEMPLATE.md
  • aec6cd6 chore: cleanup unused code (ealush)
  • 0103b38 lint: handling lint of all packages (ealush)
  • .gitignore
  • 03cf487 patch(n4s): add ruleReturn default values (ealush)
  • 76e8c98 fix(n4s): make enforce compound runners fall back to correct response (ealush)
  • ff91bd2 fix(n4s): make enforce chaining work (ealush)
  • c3fd912 chore: some lint fixes (ealush)
  • 49b6b84 Vest 4 Infra Setup (ealush)

1.1.14 - 2021-07-02

Fixed and improved

  • 34e0414 improved conditions (undefined)
  • 26c28c6 all tests pass (undefined)
  • 33f4e46 release (undefined)
  • 6fe40c7 better bundle (undefined)
  • c2cfb65 better typing (undefined)
  • c6387ab before ts settings (undefined)
  • c0e9708 generate correct d.ts file (undefined)
  • 8e01b8e x (undefined)
  • afb3960 x (undefined)
  • e0a8463 add changelog support (undefined)
  • cc46c38 current (undefined)
  • b6db1c6 transform any to unknowns (ealush)