Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 8, 2024 via pnpm

async-validator 4.2.5

validate form asynchronous
Package summary
Share
0
issues
1
license
1
MIT
Package created
10 Mar 2015
Version published
17 Jun 2022
Maintainers
2
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
async-validator@4.2.5
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of async-validator 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does async-validator do?

The async-validator is a powerful JavaScript library that allows asynchronous form validation. It can handle a wide variety of validation checks such as string, number, boolean, regular expressions, object, array, date, URL, email, and hex, amongst others. Additionally, it offers type checking, required field checking, pattern matching, ranges, lengths, enumerables, deep rules, and message customization, making it an all-in-one solution for validating form fields in an asynchronous way.

How do you use async-validator?

To use async-validator, you need to define a descriptor, assign it to a schema, and pass the object to be validated and a callback function to the 'validate' method of the schema. Here's an example of how to use it:

import Schema from 'async-validator';

const descriptor = {
  name: {
    type: 'string',
    required: true,
    validator: (rule, value) => value === 'muji',
  },
  age: {
    type: 'number',
    asyncValidator: (rule, value) => {
      return new Promise((resolve, reject) => {
        if (value < 18) {
          reject('too young');  // reject with error message
        } else {
          resolve();
        }
      });
    },
  },
};

const validator = new Schema(descriptor);

validator.validate({ name: 'muji', age: 16 }).then(() => {
  // validation passed or without error message
}).catch(({ errors, fields }) => {
  return handleErrors(errors, fields);
});

In this code, a schema is created with two fields (name and age) which need to be validated. The name field must be a string and its value must be 'muji'. The age field must be a number and it cannot be less than 18.

Where are the async-validator docs?

The detailed documentation for async-validator containing all its usage details, API reference, rules, and FAQ can be found directly on its GitHub page where you can explore the repository's readme file for a comprehensive understanding of its features, installation, usage, faq, test cases, and license details. For particularities about the more advanced usage variants and behaviors, you should refer to the examples and explanations provided in the readme file.