async-validate
Advanced tools
Comparing version 0.4.13 to 0.4.14
@@ -223,2 +223,3 @@ ## Guide | ||
* `method`: Must be of type `function`. | ||
* `null`: Must strictly equal `null`. | ||
* `regexp`: Must be an instance of `RegExp` or a string that does not generate an exception when creating a new `RegExp`. | ||
@@ -225,0 +226,0 @@ * `integer`: Must be of type `number` and an integer. |
var types = {}; | ||
types.null = function(value) { | ||
return value === null; | ||
} | ||
types.integer = function(value) { | ||
@@ -4,0 +8,0 @@ return typeof(value) === 'number' && parseInt(value) === value; |
@@ -121,3 +121,4 @@ var plugin = require('zephyr') | ||
function type() { | ||
var custom = ['integer', 'float', 'array', 'regexp', 'object', 'method'] | ||
var custom = [ | ||
'integer', 'float', 'array', 'regexp', 'object', 'method', 'null'] | ||
, rule = this.rule | ||
@@ -130,3 +131,3 @@ , value = this.value | ||
// no need to add this error message | ||
if(rule.required && (value === undefined || value === null)) { | ||
if(rule.required && (value === undefined)) { | ||
return; | ||
@@ -133,0 +134,0 @@ } |
@@ -16,2 +16,3 @@ /** | ||
string: '%s is not a %s', | ||
null: '%s is not %s', | ||
method: '%s is not a %s (function)', | ||
@@ -18,0 +19,0 @@ array: '%s is not an %s', |
{ | ||
"name": "async-validate", | ||
"description": "Asynchronous validation for object properties.", | ||
"version": "0.4.13", | ||
"version": "0.4.14", | ||
"author": "muji <noop@xpm.io>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
@@ -10,2 +10,3 @@ var validator = require('../lib/validator'); | ||
require('./method'), | ||
require('./null'), | ||
require('./number'), | ||
@@ -12,0 +13,0 @@ require('./object'), |
@@ -315,2 +315,3 @@ Table of Contents | ||
* `method`: Must be of type `function`. | ||
* `null`: Must strictly equal `null`. | ||
* `regexp`: Must be an instance of `RegExp` or a string that does not generate an exception when creating a new `RegExp`. | ||
@@ -317,0 +318,0 @@ * `integer`: Must be of type `number` and an integer. |
@@ -54,5 +54,5 @@ var assert = require('chai').assert; | ||
validator.validate({name: null}, function(errors, fields) { | ||
assert.equal(errors.length, 1); | ||
assert.equal(errors.length, 2); | ||
assert.equal(errors[0].message, "name is required"); | ||
assert.equal(fields.name.length, 1); | ||
assert.equal(fields.name.length, 2); | ||
done(); | ||
@@ -59,0 +59,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128130
76
2785
718