1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-data.Errors'>/**
2 </span> * @author Ed Spencer
3 * @class Ext.data.Errors
4 * @extends Ext.util.MixedCollection
6 * <p>Wraps a collection of validation error responses and provides convenient functions for
7 * accessing and errors for specific fields.</p>
9 * <p>Usually this class does not need to be instantiated directly - instances are instead created
10 * automatically when {@link Ext.data.Model#validate validate} on a model instance:</p>
12 <pre><code>
13 //validate some existing model instance - in this case it returned 2 failures messages
14 var errors = myModel.validate();
16 errors.isValid(); //false
19 errors.getByField('name'); // [{field: 'name', error: 'must be present'}]
20 errors.getByField('title'); // [{field: 'title', error: 'is too short'}]
21 </code></pre>
23 Ext.define('Ext.data.Errors', {
24 extend: 'Ext.util.MixedCollection',
26 <span id='Ext-data.Errors-method-isValid'> /**
27 </span> * Returns true if there are no errors in the collection
31 return this.length === 0;
34 <span id='Ext-data.Errors-method-getByField'> /**
35 </span> * Returns all of the errors for the given field
36 * @param {String} fieldName The field to get errors for
37 * @return {Array} All errors for the given field
39 getByField: function(fieldName) {
43 for (i = 0; i < this.length; i++) {
44 error = this.items[i];
46 if (error.field == fieldName) {
54 </pre></pre></body></html>