Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-validator

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-validator

validate form asynchronous

  • 1.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by9.35%
Maintainers
1
Weekly downloads
 
Created

What is async-validator?

The async-validator package is a JavaScript library for asynchronous form validation. It allows developers to define validation rules and apply them to data objects, handling both synchronous and asynchronous validation scenarios. It is commonly used in web development to validate form inputs on the client side before submitting data to a server.

What are async-validator's main functionalities?

Schema Definition and Validation

Define a schema with validation rules and apply it to a data object. The example code defines a rule that requires a string with a minimum length of 5 characters and validates the value 'Hello World' against this rule.

{"rule": {"type": "string", "required": true, "min": 5}, "value": "Hello World"}

Custom Validators

Create custom validation functions for more complex or specific validation scenarios. The example code shows a custom validator that checks if the value is equal to 'expected' and returns an error if it is not.

{"rule": {"validator": "(rule, value, callback) => { if (value !== 'expected') { callback(new Error('Value is not expected!')); } else { callback(); } }"}, "value": "unexpected"}

Asynchronous Validation

Perform asynchronous operations within your validation rules. The example code demonstrates an asynchronous validator that resolves if the value is 'async' and rejects with an error message otherwise.

{"rule": {"validator": "(rule, value) => new Promise((resolve, reject) => { setTimeout(() => { if (value === 'async') { resolve(); } else { reject('Value must be async'); } }, 1000); })"}, "value": "async"}

Other packages similar to async-validator

Keywords

FAQs

Package last updated on 30 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc