@@ -1555,21 +1555,22 @@ <h2 id="Model">Backbone.Model</h2>
15551555 < br />
15561556 This method is left undefined and you're encouraged to override it with
15571557 any custom validation logic you have that can be performed in JavaScript.
1558- By default < tt > save</ tt > checks < b > validate</ b > before
1558+ If the attributes are valid, don't return anything from < b > validate</ b > ;
1559+ if they are invalid return an error of your choosing. It can be as
1560+ simple as a string error message to be displayed, or a complete error
1561+ object that describes the error programmatically.
1562+ </ p >
1563+
1564+ < p >
1565+ By default < tt > save</ tt > checks < b > validate</ b > before
15591566 setting any attributes but you may also tell < tt > set</ tt > to validate
15601567 the new attributes by passing < tt > {validate: true}</ tt > as an option.
1561- < br />
15621568 The < b > validate</ b > method receives the model attributes as well as any
1563- options passed to < tt > set</ tt > or < tt > save</ tt > .
1564- If the attributes are valid, don't return anything from < b > validate</ b > ;
1565- if they are invalid return an error of your choosing. It
1566- can be as simple as a string error message to be displayed, or a complete
1567- error object that describes the error programmatically. If < b > validate</ b >
1568- returns an error, < tt > save</ tt > will not continue, and the
1569- model attributes will not be modified on the server.
1570- Failed validations trigger an < tt > "invalid"</ tt > event, and set the
1571- < tt > validationError</ tt > property on the model with the value returned by
1572- this method.
1569+ options passed to < tt > set</ tt > or < tt > save</ tt > , if < b > validate</ b >
1570+ returns an error, < tt > save</ tt > does not continue, the model attributes
1571+ are not modified on the server, an < tt > "invalid"</ tt > event is triggered,
1572+ and the < tt > validationError</ tt > property is set on the model with the
1573+ value returned by this method.
15731574 </ p >
15741575
15751576< pre class ="runnable ">
@@ -1607,10 +1608,17 @@ <h2 id="Model">Backbone.Model</h2>
16071608 </ p >
16081609
16091610 < p id ="Model-isValid ">
1610- < b class ="header "> isValid</ b > < code > model.isValid()</ code >
1611+ < b class ="header "> isValid</ b > < code > model.isValid(options )</ code >
16111612 < br />
16121613 Run < a href ="#Model-validate "> validate</ a > to check the model state.
16131614 </ p >
1615+
1616+ < p >
1617+ The < tt > validate</ tt > method receives the model attributes as well as any
1618+ options passed to < b > isValid</ b > , if < tt > validate</ tt > returns an error
1619+ an < tt > "invalid"</ tt > event is triggered, and the error is set on the
1620+ model in the < tt > validationError</ tt > property.
1621+ </ p >
16141622
16151623< pre class ="runnable ">
16161624var Chapter = Backbone.Model.extend({
0 commit comments