async-validator
validate form asynchronous
async-validator is a JavaScript library for checking whether data in a form or an object meets the rules you define before you accept it. You describe what each field should look like: its type, whether it is required, any length limits, or a specific pattern it must match. The library then checks the actual values and tells you which fields failed and why.
What makes this library distinctive is that it handles checks that take time to complete, such as looking something up in a database to see if a username is already taken. Instead of freezing the page while waiting, it works in the background and finishes whenever the check resolves. You can use either a callback function or a Promise, depending on which style you prefer in your code.
The rules you can define cover a wide range of common cases: string, number, boolean, email address, URL, date, integer, floating-point number, array, object, or a custom regular expression pattern. You can also mark a field as optional or required, set minimum and maximum lengths, check that a value belongs to a fixed list of allowed choices, or write a completely custom validation function when the built-in types are not enough.
When multiple rules apply to a single field you can stack them in an array, and the library works through each in order. Options let you stop after the very first error found, either for the whole form or field by field, which is useful when you want to avoid running expensive database queries unnecessarily.
The library is available as an npm package and is widely used as the validation engine inside popular component libraries for web applications. The README covers installation, all rule types, error message customization, and how to handle nested object and array structures.