Comparing version 0.0.4 to 0.0.6
@@ -22,2 +22,9 @@ var defaults = require("./defaults"), | ||
"tester": function() { | ||
return testers.create(); | ||
}, | ||
/** | ||
*/ | ||
get: function(name) { | ||
@@ -24,0 +31,0 @@ return testers.get(name); |
@@ -8,5 +8,6 @@ var structr = require("structr"); | ||
"__construct": function(testers) { | ||
"__construct": function(testers, pos) { | ||
this._testers = testers; | ||
this._source = []; | ||
this._pos = pos !== undefined; | ||
}, | ||
@@ -40,10 +41,8 @@ | ||
"test": function(value) { | ||
if(!this._source.length) return false; | ||
for(var i = 0, n = this._source.length; i < n; i++) { | ||
var match = this._source[i]; | ||
if(!match.test(value)) return false; | ||
if(!match.test(value)) return !this._pos; | ||
} | ||
return true; | ||
return this._pos; | ||
}, | ||
@@ -50,0 +49,0 @@ |
@@ -6,3 +6,4 @@ var structr = require("structr"), | ||
validator = require("validator"), | ||
check = validator.check; | ||
check = validator.check, | ||
toarray = require("toarray"); | ||
@@ -15,2 +16,3 @@ module.exports = structr({ | ||
"__construct": function(options) { | ||
this._testers = options.testers; | ||
@@ -21,3 +23,3 @@ this.name = options.name; | ||
this._sanitizers = new Sanitizers(); | ||
this._is = new Matchers(this._testers); | ||
this._is = new Matchers(this._testers, true); | ||
this._not = new Matchers(this._testers); | ||
@@ -54,5 +56,13 @@ | ||
/** | ||
* DEPRECATED | ||
*/ | ||
"addSanitizer": function(match, sanitizer) { | ||
"addSanitizer": function() { | ||
this.sanitize.apply(this, arguments); | ||
}, | ||
/** | ||
*/ | ||
"sanitize": function(match, sanitizer) { | ||
this._sanitizers.add(match, sanitizer); | ||
@@ -66,3 +76,3 @@ return this; | ||
"test": function(value) { | ||
return !!value && this._is.test(value) && !this._not.test(value); | ||
return value !== undefined && this._is.test(value) && !this._not.test(value); | ||
}, | ||
@@ -73,2 +83,12 @@ | ||
"match": function(options) { | ||
for(var key in options) { | ||
this[key].apply(this, toarray(options[key])); | ||
} | ||
return this; | ||
}, | ||
/** | ||
*/ | ||
"sanitize": function(value) { | ||
@@ -75,0 +95,0 @@ var newValue = this._is.sanitize(value); |
@@ -18,3 +18,11 @@ var structr = require("structr"), | ||
"register": function(name, message) { | ||
return this._source[name] = new Tester({ | ||
return this._source[name] = this.create(name, message); | ||
}, | ||
/** | ||
*/ | ||
"create": function(name, message) { | ||
return new Tester({ | ||
testers: this, | ||
@@ -21,0 +29,0 @@ name: name, |
{ | ||
"name": "verify", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"description": "```javascript", | ||
@@ -12,7 +12,11 @@ "main": "./lib/index.js", | ||
"structr": "0.2.x", | ||
"comerr": "0.0.x" | ||
"comerr": "0.0.x", | ||
"toarray": "0.0.x" | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"mocha": "1.8.x", | ||
"expect.js": "0.2.x" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "mocha --reporter min" | ||
}, | ||
@@ -19,0 +23,0 @@ "repository": { |
@@ -5,3 +5,3 @@ ```javascript | ||
verify.register("email", "Invalid email").match(/regexp/).len(6, 64); | ||
verify.register("email", "Invalid email").is(/regexp/).len(6, 64); | ||
verify.register("name", "Invalid name").len(2); | ||
@@ -8,0 +8,0 @@ verify.register("phoneNumber", "Invalid phone number").sanitize(/\d+\-\d+\-\d+/, function(number) { |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
10880
14
409
2
4
2
+ Addedtoarray@0.0.x
+ Addedtoarray@0.0.1(transitive)