documentcloud/backbone — pull request #2489 by akre54 (2013-04-16 21:19:44+00:00)
Title: Return a rejected promise instead of false on invalid model save

From the discussion in #2345, returning false from a failed save prevents a clean chaining API (`model.save(...).done(...).fail(...)`). Using deferreds, we can reject a promise instead to avoid the discrepancy.

This pull doesn't introduce any new options vars (i.e. `isValid`), instead suggesting a separate event listener for the model's `invalid` event or querying `model.isValid()` directly within the failed handler. The `invalid` event will always be fired before the deferred is rejected and returned. The fail handler is fired for both failed validation as well as any ajax errors which makes it difficult to mutate the options object or keep the two callbacks' arguments consistent.