From 47955c05b84eb6facfb37306656f7a01374ede47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andr=C3=A9s=20Arturo?= Backbone.Model
This method is left undefined and you're encouraged to override it with
any custom validation logic you have that can be performed in JavaScript.
- By default save checks validate before
+ If the attributes are valid, don't return anything from validate;
+ if they are invalid return an error of your choosing. It can be as
+ simple as a string error message to be displayed, or a complete error
+ object that describes the error programmatically.
+
+ By default save checks validate before
setting any attributes but you may also tell set to validate
the new attributes by passing {validate: true} as an option.
-
The validate method receives the model attributes as well as any
- options passed to set or save.
- If the attributes are valid, don't return anything from validate;
- if they are invalid return an error of your choosing. It
- can be as simple as a string error message to be displayed, or a complete
- error object that describes the error programmatically. If validate
- returns an error, save will not continue, and the
- model attributes will not be modified on the server.
- Failed validations trigger an "invalid" event, and set the
- validationError property on the model with the value returned by
- this method.
+ options passed to set or save, if validate
+ returns an error, save does not continue, the model attributes
+ are not modified on the server, an "invalid" event is triggered,
+ and the validationError property is set on the model with the
+ value returned by this method.
@@ -1607,10 +1608,17 @@Backbone.Model
- isValid
+ +model.isValid()
+ isValidmodel.isValid(options)
Run validate to check the model state.+ The validate method receives the model attributes as well as any + options passed to isValid, if validate returns an error + an "invalid" event is triggered, and the error is set on the + model in the validationError property. +
var Chapter = Backbone.Model.extend({