code: function(attrs, setOptions){
            var model = this,
                validateAll = !attrs,
                opt = _.extend({}, options, setOptions),
                validatedAttrs = getValidatedAttrs(model, getOptionsAttrs(options, view)),
                allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs),
                flattened = flatten(allAttrs),
                changedAttrs = attrs ? flatten(attrs) : flattened,
                result = validateModel(model, allAttrs, _.pick(flattened, _.keys(validatedAttrs)));
  
            model._isValid = result.isValid;
  
            //After validation is performed, loop through all associated views
            _.each(model.associatedViews, function(view){
  
              // After validation is performed, loop through all validated and changed attributes
              // and call the valid and invalid callbacks so the view is updated.
              _.each(validatedAttrs, function(val, attr){
                  var invalid = result.invalidAttrs.hasOwnProperty(attr),
                    changed = changedAttrs.hasOwnProperty(attr);
  
                  if(!invalid){
                    opt.valid(view, attr, opt.selector);
                  }
                  if(invalid && (changed || validateAll)){
                    opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector);
                  }
              });
            });
  
            // Trigger validated events.
            // Need to defer this so the model is actually updated before
            // the event is triggered.
            _.defer(function() {
              model.trigger('validated', model._isValid, model, result.invalidAttrs);
              model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
            });
  
            // Return any error messages to Backbone, unless the forceUpdate flag is set.
            // Then we do not return anything and fools Backbone to believe the validation was
            // a success. That way Backbone will update the model regardless.
            if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
              return result.invalidAttrs;
            }
          }
docs: This is called by Backbone when it needs to perform validation. You can call it manually without any parameters to validate the entire model.