New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-validate

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-validate - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

27

doc/readme/usage.md

@@ -290,29 +290,2 @@ ## Usage

## Register
To extend the recognised validation types you may `register` your own validation functions by type.
```javascript
function register(type, validator)
```
The `type` arguments should be a string indicating the `type` property of the validation rule and `validator` must be a function with the correct signature.
```javascript
var schema = require('async-validate');
var ValidationError = schema.ValidationError;
var validator = function(rule, value, callback, source, options) {
var errors = [];
var re = /^[^-][a-zA-Z0-9-]+$/;
if(!re.test(value)) {
errors.push(new ValidationError(
util.format("%s is not a valid identifier", rule.field)));
}
callback(errors);
}
schema.register('id', validator);
```
You can then use validation rules such as `{type: "id"}`.
## Messages

@@ -319,0 +292,0 @@

2

package.json
{
"name": "async-validate",
"description": "Asynchronous validation for object properties.",
"version": "0.3.1",
"version": "0.3.2",
"author": "muji <noop@xpm.io>",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -24,3 +24,2 @@ Table of Contents

* [Transform](#transform)
* [Register](#register)
* [Messages](#messages)

@@ -347,29 +346,2 @@ * [Standard Rules](#standard-rules)

## Register
To extend the recognised validation types you may `register` your own validation functions by type.
```javascript
function register(type, validator)
```
The `type` arguments should be a string indicating the `type` property of the validation rule and `validator` must be a function with the correct signature.
```javascript
var schema = require('async-validate');
var ValidationError = schema.ValidationError;
var validator = function(rule, value, callback, source, options) {
var errors = [];
var re = /^[^-][a-zA-Z0-9-]+$/;
if(!re.test(value)) {
errors.push(new ValidationError(
util.format("%s is not a valid identifier", rule.field)));
}
callback(errors);
}
schema.register('id', validator);
```
You can then use validation rules such as `{type: "id"}`.
## Messages

@@ -376,0 +348,0 @@

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