Skip to content

Commit

Permalink
Merge pull request jashkenas#2172 from tgriesser/validationError
Browse files Browse the repository at this point in the history
Documenting validationError
  • Loading branch information
braddunbar committed Jan 21, 2013
2 parents dbb7e9e + e716b86 commit 9e2cf08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,9 @@
// A hash of attributes whose current and previous value differ.
changed: null,

// The value returned during the last failed validation.
validationError: null,

// The default name for the JSON `id` attribute is `"id"`. MongoDB and
// CouchDB users may want to set this to `"_id"`.
idAttribute: 'id',
Expand Down
11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
<li><a href="#Model-save">save</a></li>
<li><a href="#Model-destroy">destroy</a></li>
<li><a href="#Model-validate">validate</a></li>
<li><a href="#Model-validationError">validationError</a></li>
<li><a href="#Model-url">url</a></li>
<li><a href="#Model-urlRoot">urlRoot</a></li>
<li><a href="#Model-parse">parse</a></li>
Expand Down Expand Up @@ -1283,7 +1284,9 @@ <h2 id="Model">Backbone.Model</h2>
error object that describes the error programmatically. If <b>validate</b>
returns an error, <tt>set</tt> and <tt>save</tt> will not continue, and the
model attributes will not be modified.
Failed validations trigger an <tt>"invalid"</tt> event.
Failed validations trigger an <tt>"invalid"</tt> event, and set the
<tt>validationError</tt> property on the model with the value returned by
this method.
</p>

<pre class="runnable">
Expand Down Expand Up @@ -1314,6 +1317,12 @@ <h2 id="Model">Backbone.Model</h2>
messages at the model or collection level.
</p>

<p id="Model-validationError">
<b class="header">validationError</b><code>model.validationError</code>
<br />
The value returned by <a href="#Model-validate">validate</a> during the last failed validation.
</p>

<p id="Model-url">
<b class="header">url</b><code>model.url()</code>
<br />
Expand Down

0 comments on commit 9e2cf08

Please sign in to comment.