Skip to content

Commit

Permalink
Fix jashkenas#1179 - isValid returns true in the absence of validate.
Browse files Browse the repository at this point in the history
  • Loading branch information
braddunbar committed Apr 4, 2012
1 parent a2ed079 commit 137b7fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
// Check if the model is currently in a valid state. It's only possible to
// get into an *invalid* state if you're using silent changes.
isValid: function() {
return !this.validate(this.attributes);
return !this.validate || !this.validate(this.attributes);
},

// Run validation against the next complete set of model attributes,
Expand Down
6 changes: 6 additions & 0 deletions test/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -784,4 +784,10 @@ $(document).ready(function() {
}
});

test("#1179 - isValid returns true in the absence of validate.", function() {
var model = new Backbone.Model();
model.validate = null;
ok(model.isValid());
});

});

0 comments on commit 137b7fd

Please sign in to comment.