Getting started
Installation
The library contains both ESM and CJS uncompressed modules. Depending on your project setup, you may need to configure a module bundler.
For browser only usage, you can pull the library using CDN like jsdelivr.com or esm.sh.
Usage
-
Define predicate functions:
You can also use validators from another library like validator.js:
-
Create
Validation
objects: -
Add the predicate functions as common (shared between forms) constraints to the validations:
-
Create validation profiles (bind the validations to form fields):
-
Add form-specific and environment-specific constraints to cloned validations:
-
Add grouping validations as event handlers and middleware functions:
For the client side:
For the server side:
-
Connect side effects to validators’ and validations’ validity states:
-
Don’t forget about error handling:
You can see in action the client side part of a similar example on the Validation.profile()
method page.