Skip to content

Commit

Permalink
removing unnecessary options check
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Dec 27, 2012
1 parent e12e1d8 commit 03f1de0
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions backbone.js
Expand Up @@ -536,8 +536,7 @@
// returning `true` if all is well. Otherwise, fire a general // returning `true` if all is well. Otherwise, fire a general
// `"error"` event and call the error callback, if specified. // `"error"` event and call the error callback, if specified.
_validate: function(attrs, options) { _validate: function(attrs, options) {
if (!options || !options.validate || !this.validate) return true; if (!options.validate || !this.validate) return true;
options || (options = {});
attrs = _.extend({}, this.attributes, attrs); attrs = _.extend({}, this.attributes, attrs);
var error = this.validationError = this.validate(attrs, options) || null; var error = this.validationError = this.validate(attrs, options) || null;
if (!error) return true; if (!error) return true;
Expand Down

2 comments on commit 03f1de0

@braddunbar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @caseywebdev added this one to ensure that Model#validate always gets options (even if they're empty). I agree that it's not strictly necessary, but it's definitely more friendly and consistent. I'll pull request with a test.

@braddunbar
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it seems that this is always handled by the calling function. Should've checked first. Sorry to bother @tgriesser. :)

Please sign in to comment.