Comparing version 0.0.4 to 0.0.5
42
index.js
@@ -171,5 +171,5 @@ (function(root){ | ||
} | ||
if (options.catch) { | ||
this.catch(options.catch); | ||
delete options.catch; | ||
if (options.invalid) { | ||
this.invalid(options.invalid); | ||
delete options.invalid; | ||
} | ||
@@ -217,3 +217,3 @@ } | ||
catch: function () { | ||
invalid: function () { | ||
if (arguments.length == 2) { | ||
@@ -225,3 +225,3 @@ var props = arguments[0], fn = arguments[1], prop; | ||
if (prop) { | ||
prop.catch = fn; | ||
prop.invalid = fn; | ||
this._props[props[key]] = prop; | ||
@@ -231,3 +231,3 @@ } | ||
} else { | ||
this._catchAll = arguments[0]; | ||
this._invalidAll = arguments[0]; | ||
} | ||
@@ -256,5 +256,5 @@ return this; | ||
} | ||
if (options.catch) { | ||
this.catch(name, options.catch); | ||
delete options.catch; | ||
if (options.invalid) { | ||
this.invalid(name, options.invalid); | ||
delete options.invalid; | ||
} | ||
@@ -302,5 +302,5 @@ } | ||
return function (error){ | ||
if (prop.catch) { | ||
if (prop.invalid) { | ||
try { | ||
prop.catch(obj); | ||
prop.invalid(obj); | ||
} catch (e) { | ||
@@ -325,5 +325,5 @@ error = e; | ||
if (_errors.length) { | ||
if (th._catchAll) { | ||
if (th._invalidAll) { | ||
try { | ||
th._catchAll(obj); | ||
th._invalidAll(obj); | ||
} catch (e) { | ||
@@ -413,3 +413,3 @@ _errors = [e]; | ||
this.validations = []; | ||
this.propCatches = {}; | ||
this.propInvalids = {}; | ||
if (arguments[0]) this.rule.apply(this, arguments); | ||
@@ -470,3 +470,3 @@ } | ||
catch: function () { | ||
invalid: function () { | ||
var fn, props, prop; | ||
@@ -479,7 +479,7 @@ if (arguments.length == 2) { | ||
prop = props[key]; | ||
this.propCatches[prop] = fn; | ||
this.propInvalids[prop] = fn; | ||
} | ||
} else { | ||
fn = arguments[0]; | ||
this._catch = fn; | ||
this._invalid = fn; | ||
} | ||
@@ -504,5 +504,5 @@ return this; | ||
if (errors.length) { | ||
if (th._catch) { | ||
if (th._invalid) { | ||
try { | ||
th._catch(name); | ||
th._invalid(name); | ||
} catch (e) { | ||
@@ -512,3 +512,3 @@ errors = [e]; | ||
} else { | ||
for (var name in th.propCatches) { | ||
for (var name in th.propInvalids) { | ||
for (var key in errors) { | ||
@@ -519,3 +519,3 @@ error = errors[key]; | ||
try { | ||
th.propCatches[name](obj); | ||
th.propInvalids[name](obj); | ||
} catch (e) { | ||
@@ -522,0 +522,0 @@ errors.push(e); |
{ | ||
"name": "credible", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"author": "Noah Portes Chaikin <noah.porteschaikin@carrotcreative.com>", | ||
@@ -5,0 +5,0 @@ "description": "Unopinionated validation framework for node and the browser.", |
@@ -75,3 +75,3 @@ credible | ||
All rules have `if`, `unless`, and `catch` options -- pass functions. | ||
All rules have `if`, `unless`, and `invalid` options -- pass functions. | ||
@@ -82,3 +82,3 @@ ```javascript | ||
.unless([properties], fn); | ||
.catch([properties], fn); | ||
.invalid([properties], fn); | ||
``` | ||
@@ -85,0 +85,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23375
0