mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge pull request #3498 from akre54/validate-docs
Fix wording in validate docs
This commit is contained in:
16
index.html
16
index.html
@@ -1493,14 +1493,16 @@ chapters.keys().join(', ');
|
||||
<p id="Model-validate">
|
||||
<b class="header">validate</b><code>model.validate(attributes, options)</code>
|
||||
<br />
|
||||
This method is left undefined, and you're encouraged to override it with
|
||||
your custom validation logic, if you have any that can be performed
|
||||
in JavaScript. By default <b>validate</b> is called before
|
||||
<tt>save</tt>, but can also be called before <tt>set</tt> if
|
||||
<tt>{validate:true}</tt> is passed. The <b>validate</b> method is passed
|
||||
the model attributes, as well as the options from <tt>set</tt> or <tt>save</tt>.
|
||||
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 <tt>save</tt> checks <b>validate</b> before
|
||||
setting any attributes but you may also tell <tt>set</tt> to validate
|
||||
the new attributes by passing <tt>{validate: true}</tt> as an option.
|
||||
<br />
|
||||
The <b>validate</b> method receives the model attributes as well as any
|
||||
options passed to <tt>set</tt> or <tt>save</tt>.
|
||||
If the attributes are valid, don't return anything from <b>validate</b>;
|
||||
if they are invalid, return an error of your choosing. It
|
||||
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 <b>validate</b>
|
||||
returns an error, <tt>save</tt> will not continue, and the
|
||||
|
||||
Reference in New Issue
Block a user