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.3 to 0.6.4

plugin/util.js

4

doc/example/string.js

@@ -8,3 +8,5 @@ var Schema = require('../../')

Schema.plugin([require('../../plugin/string')]);
Schema.plugin([
require('../../plugin/util'),
require('../../plugin/string')]);

@@ -11,0 +13,0 @@ var schema = new Schema(descriptor);

@@ -9,4 +9,4 @@ var Schema = require('../../')

Schema.plugin([
require('../plugin/core'),
require('../plugin/string')]);
require('../../plugin/util'),
require('../../plugin/string')]);

@@ -13,0 +13,0 @@ var schema = new Schema(descriptor);

@@ -15,3 +15,3 @@ var Schema = require('..')

Schema.plugin([
require('../plugin/core'),
require('../plugin/util'),
require('../plugin/string')]);

@@ -18,0 +18,0 @@

@@ -7,3 +7,3 @@ var Schema = require('..')

Schema.plugin([
require('../plugin/core'),
require('../plugin/util'),
require('../plugin/string')]);

@@ -10,0 +10,0 @@

@@ -26,2 +26,8 @@ /**

},
function: {
len: '%s must have exactly %s arguments',
min: '%s must have at least %s arguments',
max: '%s cannot have more than %s arguments',
range: '%s must have arguments length between %s and %s'
},
string: {

@@ -28,0 +34,0 @@ len: '%s must be exactly %s characters',

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

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

var rule = require('../lib/rule');
rule.plugin([
require('./core'),
require('./array'),

@@ -16,3 +15,4 @@ require('./boolean'),

require('./regexp'),
require('./string')
require('./string'),
require('./util')
]);

@@ -11,2 +11,3 @@ module.exports = function() {

this.required();
this.range();
if(typeof this.value !== 'function') {

@@ -13,0 +14,0 @@ this.raise(

@@ -84,3 +84,3 @@ Table of Contents

Schema.plugin([
require('../plugin/core'),
require('../plugin/util/required'),
require('../plugin/string')]);

@@ -501,3 +501,3 @@

Schema.plugin([
require('../plugin/core'),
require('../plugin/util/required'),
require('../plugin/string')]);

@@ -504,0 +504,0 @@

@@ -19,2 +19,56 @@ var expect = require('chai').expect

it('should error on invalid arity (len: 1)', function(done) {
var descriptor = {
mock: {type: 'method', len: 1},
}
var schema = new Schema(descriptor);
schema.validate({mock: function(){}}, function(err, res) {
expect(res.errors.length).to.eql(1);
expect(res.errors[0].message).to.eql(
'mock must have exactly 1 arguments');
done();
});
});
it('should error on invalid arity (min: 1)', function(done) {
var descriptor = {
mock: {type: 'method', min: 1},
}
var schema = new Schema(descriptor);
schema.validate({mock: function(){}}, function(err, res) {
expect(res.errors.length).to.eql(1);
expect(res.errors[0].message).to.eql(
'mock must have at least 1 arguments');
done();
});
});
it('should error on invalid arity (max: 0)', function(done) {
var descriptor = {
mock: {type: 'method', max: 0},
}
var schema = new Schema(descriptor);
schema.validate({mock: function(foo){}}, function(err, res) {
expect(res.errors.length).to.eql(1);
expect(res.errors[0].message).to.eql(
'mock cannot have more than 0 arguments');
done();
});
});
it('should error on invalid arity (min: 0, max: 1)', function(done) {
var descriptor = {
mock: {type: 'method', min: 0, max: 1},
}
var schema = new Schema(descriptor);
schema.validate({mock: function(foo, bar){}}, function(err, res) {
expect(res.errors.length).to.eql(1);
expect(res.errors[0].message).to.eql(
'mock must have arguments length between 0 and 1');
done();
});
});
it('should validate function type', function(done) {

@@ -21,0 +75,0 @@ var schema = new Schema(descriptor);

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