Comparing version 0.0.21 to 0.0.22
@@ -222,2 +222,27 @@ 'use strict'; | ||
}, { | ||
key: 'runValidationSync', | ||
value: function runValidationSync(value, allValues, name) { | ||
var _this3 = this; | ||
this.value = value; | ||
this.valid = undefined; | ||
if (!this.shouldCheckValue(value)) { | ||
this.valid = true; | ||
} | ||
var rules = this.rules.filter(function (rule) { | ||
return !rule.isAsync; | ||
}); | ||
rules.forEach(function (rule) { | ||
_this3.valid = rule.func(_this3.value); | ||
if (!_this3.valid) { | ||
_this3.messages.push((0, _formatValidationMessage2.default)(rule.failureMessage, { name: name })); | ||
} | ||
}); | ||
this.setState(this.valid, this.messages); | ||
} | ||
}, { | ||
key: 'getState', | ||
@@ -257,3 +282,3 @@ value: function getState() { | ||
this.rules = [].concat((0, _toConsumableArray3.default)(this.rules), [{ forced: forced, generator: generator, name: name, isAsync: isAsync }]); | ||
this.rules = [].concat((0, _toConsumableArray3.default)(this.rules), [{ func: func, failureMessage: failureMessage, forced: forced, generator: generator, name: name, isAsync: isAsync }]); | ||
return new ValidationUnit(this); | ||
@@ -260,0 +285,0 @@ } |
@@ -155,2 +155,13 @@ 'use strict'; | ||
}, { | ||
key: 'runValidationSync', | ||
value: function runValidationSync(name, data) { | ||
var form = this.getForm(name); | ||
(0, _keys2.default)(form).forEach(function (key) { | ||
if (data[key] === undefined) { | ||
return; | ||
} | ||
form[key].runValidationSync(data[key], data, key); | ||
}); | ||
} | ||
}, { | ||
key: 'forceValidation', | ||
@@ -157,0 +168,0 @@ value: function forceValidation(name, data) { |
{ | ||
"name": "valour", | ||
"version": "0.0.21", | ||
"version": "0.0.22", | ||
"description": "Simple javascript validation for any application", | ||
@@ -5,0 +5,0 @@ "main": "lib/valour.js", |
39602
825