https://github.com/ealush/vest
Vest ✅ Declarative validations framework
https://github.com/ealush/vest
form form-validation forms hacktoberfest javascript react-validation react-validation-library svelte-validation typescript unit-testing validation validation-library vue-validation
Last synced: about 1 month ago
JSON representation
Vest ✅ Declarative validations framework
- Host: GitHub
- URL: https://github.com/ealush/vest
- Owner: ealush
- License: mit
- Created: 2019-11-26T22:10:41.000Z (almost 7 years ago)
- Default Branch: latest
- Last Pushed: 2026-10-18T03:29:24.000Z (about 1 month ago)
- Last Synced: 2026-10-18T08:06:09.097Z (about 1 month ago)
- Topics: form, form-validation, forms, hacktoberfest, javascript, react-validation, react-validation-library, svelte-validation, typescript, unit-testing, validation, validation-library, vue-validation
- Language: TypeScript
- Homepage: https://vestjs.dev/
- Size: 21.4 MB
- Stars: 2,670
- Watchers: 12
- Forks: 94
- Open Issues: 73
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Roadmap: ROADMAP.md
Awesome Lists containing this project
- awesome-opensource-israel - Vest - Declarative validations library inspired by the spirit and style of unit testing.    (Projects by main language / typescript)
- fucking-awesome-javascript - vest - 🦺 Declarative form validation framework inspired by unit testing. (Validation)
- awesome-svelte - vest - 🦺 Declarative form validation framework inspired by unit testing. (Utilities / Forms)
- fucking-awesome-vue - vest - 🦺 Declarative form validation framework inspired by unit testing. (Components & Libraries / UI Utilities)
- awesome-list-for-developers - Vest - first-issue)_ <br> Validations framework inspired by unit testing frameworks. (JavaScript / Misc)
- awesome-vue - vest - 🦺 Declarative form validation framework inspired by unit testing. (Components & Libraries / UI Utilities)
- awesome-learning-resources - vest - Declarative form validation framework inspired by unit testing syntax. (Uncategorized / Uncategorized)
- awesome-vue - vest - 🦺 Declarative form validation framework inspired by unit testing. (Components & Libraries / UI Utilities)
- awesome-javascript - vest - 🦺 Declarative form validation framework inspired by unit testing. (Validation)
README
# Vest — form validation written like unit tests

[Documentation](https://vestjs.dev) · [Async race demo](https://vestjs.dev/#async-race-demo) · [Getting started](https://vestjs.dev/docs/get_started)
[](https://discord.gg/WmADZpJnSe) [](https://github.com/ealush/vest) [](https://www.npmjs.com/package/vest) [](https://www.npmjs.com/package/vest) [](https://bundlephobia.com/package/vest) [](https://github.com/ealush/vest/actions)
Vest runs the tests for the field or step that changed and keeps the results for everything else. When async checks overlap, only the latest result can update the suite.
> **Vest validates what changed, remembers what already passed, and prevents stale async validation results.**
The validation rules read like unit tests. The stateful runtime is what makes Vest different.
```js
import { create, enforce, test } from 'vest';
const suite = create(data => {
test('username', 'Username is required', () => {
enforce(data.username).isNotBlank();
});
test('username', 'Username must be at least 3 characters', () => {
enforce(data.username).longerThanOrEquals(3);
});
test('username', 'Username is already taken', async ({ signal }) => {
const response = await checkUsername(data.username, { signal });
enforce(response.available).isTruthy();
});
});
// Run only username tests and retain previous results for every other field.
const result = suite.only('username').run(formData);
result.isPending('username');
result.hasErrors('username');
// Await the current async run when final completion matters.
await result;
```
## Why Vest?
- **Incremental execution:** Validate a field, group, or step without rerunning everything.
- **Retained validation state:** A focused run updates part of the existing result instead of replacing it.
- **Race-safe async:** Track pending work, cancel obsolete requests, and ignore stale completions.
- **Real workflow primitives:** Model dependent fields, conditional sections, warnings, optional values, groups, and dynamic lists.
- **Client and server continuity:** Run statelessly on the server and resume full validation state in the browser.
- **Framework independence:** Use the same suite with React, Vue, Svelte, Angular, vanilla JavaScript, or Node.js.
- **TypeScript and schemas:** Infer typed inputs and parsed outputs with Enforce schemas.
- **Standard Schema interoperability:** Pass suites and Enforce rules to compatible tools while keeping `run()` and `runStatic()` as Vest's execution APIs.
- **Familiar, testable rules:** Keep business validation outside UI components in suites that are easy to unit-test.
## Where Vest fits
| Layer | Responsibility | Typical tools |
| -------------------- | ----------------------------------------------------------- | ---------------------------------- |
| Form state | Values, registration, touched state, submission | React Hook Form, Formik |
| Data boundary | Parse and protect a complete payload | Zod, Valibot, Ajv, Enforce schemas |
| **Validation state** | Decide what runs now, retain results, coordinate async work | **Vest** |
These layers are complementary. A common architecture uses a form manager for input mechanics, Vest for progressive interaction, and a schema validator for the final submitted boundary.
## Where Vest works well
Vest works well for:
- async username, email, inventory, coupon, or eligibility checks;
- onboarding and multi-step workflows;
- linked fields and cross-field business rules;
- warnings that should not block submission;
- optional and conditional sections;
- dynamic lists of travelers, products, or addresses;
- rules shared between browser and server;
- SSR workflows that should not validate everything twice.
For a trivial synchronous form or a one-shot API parse, native HTML validation or a schema validator may be all you need.
## Installation
```shell
npm i vest
```
## Start here
- [Getting started](https://vestjs.dev/docs/get_started)
- [Vest tutorials](https://vestjs.dev/docs/tutorials)
- [How Vest handles validation](https://vestjs.dev/docs/concepts)
- [Async validation without race conditions](https://vestjs.dev/docs/guides/async-validation-race-conditions)
- [Complete registration example](https://vestjs.dev/docs/guides/production-architecture)
- [When not to use Vest](https://vestjs.dev/docs/guides/when-not-to-use-vest)
- [Vest, schema validators, and form libraries](https://vestjs.dev/docs/vest_vs_the_rest)
- [Consumer AI usage guide](https://vestjs.dev/llms-consumer.txt)
- [Public roadmap](https://github.com/ealush/vest/blob/latest/ROADMAP.md)
## Contributing
Contributions are welcome. See [CONTRIBUTING.md](https://github.com/ealush/vest/blob/latest/CONTRIBUTING.md).