Comparing version 0.5.0 to 0.5.1
@@ -1,2 +0,2 @@ | ||
// Checkit.js 0.5.0 | ||
// Checkit.js 0.5.1 | ||
// http://tgriesser.com/checkit | ||
@@ -7,3 +7,3 @@ // (c) 2013-2015 Tim Griesser | ||
var createError = require('create-error') | ||
var Promise = require('when/es6-shim/Promise') | ||
var Promise = require('when').Promise | ||
var inherits = require('inherits') | ||
@@ -21,9 +21,8 @@ | ||
this.messages = options.messages || {}; | ||
this.language = Checkit.i18n[options.language || Checkit.language]; | ||
this.language = Checkit.i18n[options.language || Checkit.language] || {}; | ||
this.labelTransform = options.labelTransform || Checkit.labelTransform | ||
this.validations = prepValidations(validations || {}); | ||
this.validator = new Validator(this) | ||
}; | ||
Checkit.VERSION = '0.5.0'; | ||
Checkit.VERSION = '0.5.1'; | ||
@@ -42,3 +41,3 @@ // Possibly run a validations on this object, depending on the | ||
Checkit.prototype.validate = function(target, context) { | ||
return new Runner(this).run(target, context); | ||
return new Runner(this, target, context).run(); | ||
} | ||
@@ -51,3 +50,3 @@ | ||
try { | ||
return [null, new SyncRunner(this).run(target, context)] | ||
return [null, new SyncRunner(this, target, context).run()] | ||
} catch (err) { | ||
@@ -119,6 +118,9 @@ return [err, null] | ||
// call from the `checkit.run` method. | ||
function Runner(checkit) { | ||
function Runner(checkit, target, context) { | ||
this.errors = {}; | ||
this.checkit = checkit; | ||
this.conditional = checkit.conditional; | ||
this.target = _.clone(target || {}) | ||
this.context = _.clone(context || {}) | ||
this.validator = new Validator(this.target, checkit.language) | ||
} | ||
@@ -128,5 +130,5 @@ | ||
Runner.prototype.run = function(target, context) { | ||
var runner = this; | ||
this.target = target = _.clone(target || {}) | ||
this.context = context = _.clone(context || {}) | ||
var runner = this; | ||
var target = this.target | ||
var context = this.context | ||
@@ -189,3 +191,2 @@ var validationHash = _.clone(this.checkit.validations); | ||
if((keys = key.split('.')).length === 0) return undefined; | ||
while(keys.length > 0){ | ||
@@ -207,3 +208,3 @@ value = value[keys.shift()]; | ||
} | ||
var result = runRule(runner.checkit.validator, runner, rule, params) | ||
var result = runRule(runner.validator, runner, rule, params) | ||
if (_.isBoolean(result) && result === false) { | ||
@@ -265,7 +266,6 @@ throw new ValidationError(runner.checkit.getMessage(currentValidation, key)); | ||
// Runs the validations on a specified "target". | ||
SyncRunner.prototype.run = function(target, context) { | ||
SyncRunner.prototype.run = function() { | ||
var runner = this; | ||
this.target = target = _.clone(target || {}) | ||
this.context = context = _.clone(context || {}) | ||
var target = this.target; | ||
var context = this.context; | ||
var validationHash = _.clone(this.checkit.validations); | ||
@@ -300,5 +300,5 @@ var errors = {} | ||
// Constructor for running the `Validations`. | ||
function Validator(runner) { | ||
this._language = runner.language; | ||
this._target = runner.target || {}; | ||
function Validator(target, language) { | ||
this._target = target | ||
this._language = language | ||
} | ||
@@ -305,0 +305,0 @@ |
{ | ||
"name": "checkit", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Simple validations for node and the browser.", | ||
@@ -5,0 +5,0 @@ "main": "checkit.js", |
@@ -504,2 +504,6 @@ # Checkit.js | ||
### 0.5.1 | ||
- Minor bugfixes | ||
### 0.5.0 | ||
@@ -506,0 +510,0 @@ |
@@ -10,2 +10,4 @@ | ||
matchesEmail: 'tgriesser10@gmail.com', | ||
accepted1: 'true', | ||
@@ -12,0 +14,0 @@ accepted2: '1', |
@@ -428,2 +428,6 @@ describe('Checkit', function() { | ||
it('matches', function() { | ||
return Checkit({matchesEmail: ['matchesField:email']}).validate(testBlock) | ||
}) | ||
}); | ||
@@ -430,0 +434,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
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
523
1341521
23922
16
12