if (_.contains(_.keys(validations), attr)) {
return validateAttrWithOpenArray(model, attr, value, _.extend({}, model.attributes));
} else {
indices = extractIndices(attr);
attr = stripIndices(attr);
validators = getValidators(model, attr);
return invokeValidator(validators, model, value, attr, _.extend({}, model.attributes), indices);
}
};
var mixin = function(options) {
return {
preValidate: function(attr, value) {
var self = this,
result = {},
error;
if (_.isArray(attr)) {
_.each(attr, function(attr) {
error = self.preValidate(attr);
if (error) {
result[attr] = error;
}
});
return _.isEmpty(result) ? undefined : result;
} else if (_.isObject(attr)) {
_.each(attr, function(value, key) {
error = self.preValidate(key, value);
if (error) {
result[key] = error;
}
});
return _.isEmpty(result) ? undefined : result;
} else {
if (_.isUndefined(value) && isNestedModel(this)) {
value = this.get(attr);
}
return validateAttr(this, value, attr);
}
},
isValid: function(option) {
var flattened, attrs, error, invalidAttrs;
option = option || getOptionsAttrs(options);
if(_.isString(option)){
attrs = [option];
} else if(_.isArray(option)) {
attrs = option;
}
if (attrs) {