不要怂,就是干,撸起袖子干!

Commit 04f1e1f0 by Jan Aagaard Meier

Fix for isEmail validator in iojs / node 0.12

1 parent 5346495c
Showing with 5 additions and 3 deletions
......@@ -219,6 +219,7 @@ InstanceValidator.prototype._builtinValidators = function() {
*/
InstanceValidator.prototype._customValidators = function() {
var validators = [];
var self = this;
Utils._.each(this.modelInstance.__options.validate, function(validator,
......@@ -254,8 +255,9 @@ InstanceValidator.prototype._builtinAttrValidate = function(value, field) {
var validators = [];
Utils._.forIn(this.modelInstance.validators[field], function(test,
validatorType) {
if (['isUrl', 'isURL'].indexOf(validatorType) !== -1 && test === true) {
// Preserve backwards compat. Validator.js now expects the second param to isURL to be an object
if (['isUrl', 'isURL', 'isEmail'].indexOf(validatorType) !== -1 && test === true) {
// Preserve backwards compat. Validator.js now expects the second param to isURL and isEmail to be an object
test = {};
}
......@@ -328,7 +330,6 @@ InstanceValidator.prototype._invokeCustomValidator = Promise.method(function(val
* @private
*/
InstanceValidator.prototype._invokeBuiltinValidator = Promise.method(function(value, test, validatorType, field) {
// check if Validator knows that kind of validation test
if (typeof Validator[validatorType] !== 'function') {
throw new Error('Invalid validator function: ' + validatorType);
......@@ -347,6 +348,7 @@ InstanceValidator.prototype._invokeBuiltinValidator = Promise.method(function(va
validatorArgs = validatorArgs.slice(0);
}
validatorArgs.push(field);
if (!Validator[validatorType].apply(Validator, [value].concat(validatorArgs))) {
throw errorMessage;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!