Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
async-validator
Advanced tools
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.
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"}
Joi is a powerful schema description language and data validator for JavaScript. It offers a wide range of built-in validators and is often used for object schema validation. Compared to async-validator, Joi has a more extensive API and is considered more feature-rich, but it may be heavier for client-side usage.
Yup is a lean JavaScript schema builder for value parsing and validation. It has a similar API to Joi but is more focused on client-side validation and is designed to be more lightweight. Yup provides both synchronous and asynchronous validation, making it a close alternative to async-validator.
Validator is a library of string validators and sanitizers. It is not a schema-based validation library like async-validator but provides a set of utility functions for common string validation scenarios. It is simpler and more focused on string validation rather than validating complex objects and structures.
Validate form asynchronous. A variation of https://github.com/freeformsystems/async-validate
support ie8
support type:url
type:email
type:hex
support nice nested object validation message
remove moment and async dependency
remove parallel config, defaults to true
remove type:date
support
remove .error constructor
npm install
npm start
FAQs
validate form asynchronous
The npm package async-validator receives a total of 825,217 weekly downloads. As such, async-validator popularity was classified as popular.
We found that async-validator demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.