whatisgithub

What is async-validator?

yiminghe/async-validator — explained in plain English

Analysis updated 2026-06-24

9,099TypeScriptAudience · developerComplexity · 2/5Setup · easy

In one sentence

A JavaScript and TypeScript library for validating form fields and data objects against defined rules, with built-in support for async checks like verifying a username is not already taken in a database.

Mindmap

mindmap
  root((async-validator))
    What it does
      Form data validation
      Async rule support
      Promise and callback
    Rule Types
      String number email
      URL date integer
      Custom functions
    Use Cases
      Form field validation
      Username uniqueness check
      Nested object validation
    Setup
      npm install
      No external deps
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Validate form fields with rules for type, required status, length limits, and format patterns before submitting to a server.

USE CASE 2

Run async database checks to verify a username is unique without blocking the UI during the lookup.

USE CASE 3

Stack multiple validation rules on a single field and stop at the first failure to avoid unnecessary expensive queries.

What is it built with?

TypeScriptJavaScript

How does it compare?

yiminghe/async-validatorwechat-article/wechat-article-exporterbetterdiscord/betterdiscord
Stars9,0999,0899,071
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyeasyeasy
Complexity2/52/52/5
Audiencedeveloperwriterdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
The explanation does not specify the license terms.

So what is it?

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.

Copy-paste prompts

Prompt 1
Using async-validator, write a schema that checks an email field is required, correctly formatted, and not already registered by calling an API.
Prompt 2
How do I use async-validator to validate a nested object with array fields and collect all validation errors at once?
Prompt 3
Show me how to write a custom async-validator rule that calls an external API and resolves or rejects based on the response.
Prompt 4
How do I configure async-validator to stop validation on the first error per field rather than running every rule?
Prompt 5
How do I customize the error messages in async-validator to return user-friendly text instead of the default strings?

Frequently asked questions

What is async-validator?

A JavaScript and TypeScript library for validating form fields and data objects against defined rules, with built-in support for async checks like verifying a username is not already taken in a database.

What language is async-validator written in?

Mainly TypeScript. The stack also includes TypeScript, JavaScript.

What license does async-validator use?

The explanation does not specify the license terms.

How hard is async-validator to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is async-validator for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.