On my project, the data sent by the server has changed. Small change, some foo attribute becoming foobar, but this has created havoc client-side, since I was unaware of it. It took me a very long time to figure out where errors came from.
Is there something (existing or planned) that can make backbone tell that it did not receive valid data ?
edit: More precisely, what I have in mind, is to feed BB with some kind of model definition object, detailing : field name, field length, required or optional. Something generic.
Override the validate method on your model. Backbone by default has an empty implementation and you can check for attributes manually based on your app.
validate is automatically called by Backbone when you call set or create create new models.
How to use: (From the doc)
Return any value/object except undefined if there’s an error, else return nothing (undefined).
If an error is detected, your model remains unchanged.