torso-bundle.js
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];
      }

      // Reduces the array of validators into a new array with objects
      // with a validation method to call, the value to validate against
      // and the specified error message, if any
      return _.reduce(attrValidationSet, function(memo, attrValidation) {
        _.each(_.without(_.keys(attrValidation), 'msg', 'msgKey'), function(validator) {
          memo.push({
            fn: defaultValidators[validator],
            val: attrValidation[validator],
            msg: attrValidation.msg,
            msgKey: attrValidation.msgKey
          });
        });
        return memo;
      }, []);
    }
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];
      }

      // Reduces the array of validators into a new array with objects
      // with a validation method to call, the value to validate against
      // and the specified error message, if any
      return _.reduce(attrValidationSet, function(memo, attrValidation) {
        _.each(_.without(_.keys(attrValidation), 'msg', 'msgKey'), function(validator) {
          memo.push({
            fn: defaultValidators[validator],
            val: attrValidation[validator],
            msg: attrValidation.msg,
            msgKey: attrValidation.msgKey
          });
        });
        return memo;
      }, []);
    }
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 ] ; } // Reduces the array of validators into a new array with objects // with a validation method to call, the value to validate against // and the specified error message, if any return _ . reduce ( attrValidationSet , function ( memo , attrValidation ) { _ . each ( _ . without ( _ . keys ( attrValidation ) , 'msg' , 'msgKey' ) , function ( validator ) { memo . push ( { fn : defaultValidators [ validator ] , val : attrValidation [ validator ] , msg : attrValidation . msg , msgKey : attrValidation . msgKey } ) ; } ) ; return memo ; } , [ ] ) ; }
Looks on the model for validations for a specified attribute. Returns an array of any validators defined, or an empty array if none is defined.
Looks on the model for validations for a specified attribute . Returns an array of any validators defined or an empty array if none is defined .