occamsrazor
Advanced tools
Comparing version 3.2.0 to 3.3.0
{ | ||
"name": "occamsrazor", | ||
"main": "occamsrazor.js", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"homepage": "https://github.com/sithmel/occamsrazor.js", | ||
@@ -6,0 +6,0 @@ "authors": [ |
Changelog | ||
3.3.0 (2015/12/01) | ||
================== | ||
- the "has" validator can use functions to match properties | ||
- documentation fixes | ||
- validator function has the name property set | ||
3.2.0 (2015/06/05) | ||
@@ -4,0 +11,0 @@ ================== |
@@ -66,2 +66,5 @@ /****************************************************************************** | ||
} | ||
else if (typeof o[k] === 'function'){ | ||
return o[k](obj[k]); | ||
} | ||
// undefined continue | ||
@@ -83,3 +86,3 @@ } | ||
funcs = funcs || [isAnything]; | ||
var v = function (obj){ | ||
var v = function validator(obj){ | ||
var i, score, total = 0; | ||
@@ -96,2 +99,8 @@ for (i = 0; i < funcs.length; i++) { | ||
v.prototype = { | ||
toString: function (){ | ||
return "validator"; | ||
} | ||
}; | ||
v.chain = function (func){ | ||
@@ -98,0 +107,0 @@ return _validator(funcs.concat(func)); |
{ | ||
"name": "occamsrazor", | ||
"version": "3.2.0", | ||
"version": "3.3.0", | ||
"description": "A plugin system for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "occamsrazor.js", |
@@ -412,2 +412,10 @@ /* | ||
module( "validator type" ); | ||
test("validator metadata", function() { | ||
var isAnything = occamsrazor.validator(); | ||
equal(isAnything.name, "validator", "name is correct"); | ||
}); | ||
module( "validator has" ); | ||
@@ -446,1 +454,13 @@ | ||
}); | ||
test("-has- can use functions", function() { | ||
var isAnything = occamsrazor.validator(); | ||
var hasWidthbetween5and10 = isAnything.has({width: function (w){ | ||
return w >= 5 && w <=10; | ||
}}); | ||
equal(hasWidthbetween5and10({width: 8}), 2, "match"); | ||
equal(hasWidthbetween5and10({width: 12}), null, "don't match"); | ||
equal(hasWidthbetween5and10({width: 4}), null, "don't match"); | ||
}); |
Sorry, the diff of this file is not supported yet
110991
2274
605