Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,3 @@ exports.Enforce = Enforce; | ||
this.validations = {}; | ||
this.ctx = {}; | ||
this.options = { | ||
@@ -24,2 +25,13 @@ returnAllErrors : (opts && !!opts.returnAllErrors) | ||
Enforce.prototype.context = function (name, value) { | ||
if (arguments.length === 0) { | ||
return this.ctx; | ||
} | ||
if (arguments.length == 1) { | ||
return this.ctx[name]; | ||
} | ||
this.ctx[name] = value; | ||
return this; | ||
}; | ||
Enforce.prototype.clear = function () { | ||
@@ -39,20 +51,25 @@ this.validations = {}; | ||
validation.validator(data[validation.property], function (msg) { | ||
if (msg) { | ||
var err = new Error(msg); | ||
this.ctx.property = validation.property; | ||
err.property = validation.property; | ||
err.value = data[validation.property]; | ||
err.msg = msg; | ||
err.type = "validation"; | ||
validation.validator.apply(data, [ | ||
data[validation.property], function (msg) { | ||
if (msg) { | ||
var err = new Error(msg); | ||
if (!this.options.returnAllErrors) { | ||
return cb(err); | ||
err.property = validation.property; | ||
err.value = data[validation.property]; | ||
err.msg = msg; | ||
err.type = "validation"; | ||
if (!this.options.returnAllErrors) { | ||
return cb(err); | ||
} | ||
errors.push(err); | ||
} | ||
errors.push(err); | ||
} | ||
return next(); | ||
}.bind(this)); | ||
return next(); | ||
}.bind(this), | ||
this.ctx | ||
]); | ||
}.bind(this); | ||
@@ -59,0 +76,0 @@ |
@@ -10,3 +10,3 @@ { | ||
], | ||
"version" : "0.1.0", | ||
"version" : "0.1.1", | ||
"license" : "MIT", | ||
@@ -13,0 +13,0 @@ "repository" : "http://github.com/dresende/node-enforce.git", |
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
30177
749
0