Huge News!Announcing our $40M Series B led by Abstract Ventures.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.6.2 to 0.6.3

5

doc/readme/api.md

@@ -33,4 +33,5 @@ ### API

* `first`: Invoke callback when the first validation rule generates an error, no more validation rules are processed.
* `single`: Only ever return a single error, typically used in conjunction with `first` when a validation rule could generate multiple errors.
* `first`: Invoke callback when the first validation rule generates an error.
* `single`: Only ever return a single error.
* `bail`: Shorthand for `single` and `first`.
* `keys`: Specifies the keys on the source object to be validated. Use this option to validate fields in a determinate order or to validate a subset of the rules assigned to a schema.

@@ -37,0 +38,0 @@ * `parallel`: A boolean indicating that the validation should be executed in parallel.

4

lib/reason.js

@@ -8,8 +8,6 @@ function Reason(id, meta) {

function toString() {
Reason.prototype.toString = function() {
return this.id;
}
Reason.prototype.toString = toString;
var reasons = {

@@ -16,0 +14,0 @@ type: new Reason('type'),

@@ -12,2 +12,3 @@ var plugin = require('zephyr')

}
for(var k in opts) {

@@ -50,3 +51,4 @@ this[k] = opts[k];

msg = this.rule.message
|| message || format(require('../messages').default, this.field);
|| message
|| format(require('../messages').default, this.field);
}

@@ -53,0 +55,0 @@

@@ -56,8 +56,7 @@ var iterator = require('./iterator')

function validate(source, options, cb) {
options = options || {};
if(typeof options === 'function') {
cb = options;
options = {};
options = null;
}
options = options || {};

@@ -84,6 +83,7 @@ if(!this.keys.length) {

// configure messages to use defaults where necessary
messages = options.messages || this.messages();
options.messages = messages;
if(options.bail) {
options.first = options.single = true;
}
// schema keys to iterate over
keys = options.keys || this.keys;

@@ -94,2 +94,6 @@

// configure messages to use defaults where necessary
messages = options.messages || this.messages();
options.messages = messages;
// rules for the root object

@@ -331,5 +335,3 @@ if(options.rules && !options._root) {

}
target = target || (Array.isArray(source) ? [] : {});
for(k in source) {

@@ -344,5 +346,5 @@ v = source[k];

}
return target;
}
Schema.prototype.messages = messages;

@@ -349,0 +351,0 @@ Schema.prototype.validate = validate;

{
"name": "async-validate",
"description": "Asynchronous validation for node and the browser",
"version": "0.6.2",
"version": "0.6.3",
"author": "muji <noop@xpm.io>",

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

@@ -540,4 +540,5 @@ Table of Contents

* `first`: Invoke callback when the first validation rule generates an error, no more validation rules are processed.
* `single`: Only ever return a single error, typically used in conjunction with `first` when a validation rule could generate multiple errors.
* `first`: Invoke callback when the first validation rule generates an error.
* `single`: Only ever return a single error.
* `bail`: Shorthand for `single` and `first`.
* `keys`: Specifies the keys on the source object to be validated. Use this option to validate fields in a determinate order or to validate a subset of the rules assigned to a schema.

@@ -544,0 +545,0 @@ * `parallel`: A boolean indicating that the validation should be executed in parallel.

@@ -50,2 +50,10 @@ var expect = require('chai').expect

it('should error on first error (bail)', function(done) {
var schema = new Schema(descriptor);
schema.validate({}, {bail: true}, function(err, res) {
expect(res.errors.length).to.eql(1);
done();
});
});
});
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