diff --git a/dist/backbone-validation-amd.js b/dist/backbone-validation-amd.js index 6f90e318..43db9b36 100644 --- a/dist/backbone-validation-amd.js +++ b/dist/backbone-validation-amd.js @@ -141,13 +141,6 @@ var getValidators = function(model, attr) { var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {}; - // If the validator is a function or a string, wrap it in a function validator - if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) { - attrValidationSet = { - fn: attrValidationSet - }; - } - // Stick the validator object into an array if(!_.isArray(attrValidationSet)) { attrValidationSet = [attrValidationSet]; @@ -157,6 +150,14 @@ // with a validation method to call, the value to validate against // and the specified error message, if any return _.reduce(attrValidationSet, function(memo, attrValidation) { + + // If the validator is a function or a string, wrap it in a function validator + if (_.isFunction(attrValidation) || _.isString(attrValidation)) { + attrValidation = { + fn: attrValidation + }; + } + _.each(_.without(_.keys(attrValidation), 'msg'), function(validator) { memo.push({ fn: defaultValidators[validator], @@ -715,4 +716,4 @@ return Validation; }(_)); return Backbone.Validation; -})); \ No newline at end of file +})); diff --git a/dist/backbone-validation.js b/dist/backbone-validation.js index e1d10e10..52bbe5f0 100644 --- a/dist/backbone-validation.js +++ b/dist/backbone-validation.js @@ -134,13 +134,6 @@ Backbone.Validation = (function(_){ var getValidators = function(model, attr) { var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {}; - // If the validator is a function or a string, wrap it in a function validator - if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) { - attrValidationSet = { - fn: attrValidationSet - }; - } - // Stick the validator object into an array if(!_.isArray(attrValidationSet)) { attrValidationSet = [attrValidationSet]; @@ -150,6 +143,14 @@ Backbone.Validation = (function(_){ // with a validation method to call, the value to validate against // and the specified error message, if any return _.reduce(attrValidationSet, function(memo, attrValidation) { + + // If the validator is a function or a string, wrap it in a function validator + if (_.isFunction(attrValidation) || _.isString(attrValidation)) { + attrValidation = { + fn: attrValidation + }; + } + _.each(_.without(_.keys(attrValidation), 'msg'), function(validator) { memo.push({ fn: defaultValidators[validator], @@ -706,4 +707,4 @@ Backbone.Validation = (function(_){ }); return Validation; -}(_)); \ No newline at end of file +}(_)); diff --git a/src/backbone-validation.js b/src/backbone-validation.js index e4aa8de2..869c12e4 100644 --- a/src/backbone-validation.js +++ b/src/backbone-validation.js @@ -127,13 +127,6 @@ Backbone.Validation = (function(_){ var getValidators = function(model, attr) { var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {}; - // If the validator is a function or a string, wrap it in a function validator - if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) { - attrValidationSet = { - fn: attrValidationSet - }; - } - // Stick the validator object into an array if(!_.isArray(attrValidationSet)) { attrValidationSet = [attrValidationSet]; @@ -143,6 +136,14 @@ Backbone.Validation = (function(_){ // with a validation method to call, the value to validate against // and the specified error message, if any return _.reduce(attrValidationSet, function(memo, attrValidation) { + + // If the validator is a function or a string, wrap it in a function validator + if (_.isFunction(attrValidation) || _.isString(attrValidation)) { + attrValidation = { + fn: attrValidation + }; + } + _.each(_.without(_.keys(attrValidation), 'msg'), function(validator) { memo.push({ fn: defaultValidators[validator],