4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-data-Errors'>/**
19 </span> * @author Ed Spencer
20 * @class Ext.data.Errors
21 * @extends Ext.util.MixedCollection
23 * <p>Wraps a collection of validation error responses and provides convenient functions for
24 * accessing and errors for specific fields.</p>
26 * <p>Usually this class does not need to be instantiated directly - instances are instead created
27 * automatically when {@link Ext.data.Model#validate validate} on a model instance:</p>
29 <pre><code>
30 //validate some existing model instance - in this case it returned 2 failures messages
31 var errors = myModel.validate();
33 errors.isValid(); //false
36 errors.getByField('name'); // [{field: 'name', message: 'must be present'}]
37 errors.getByField('title'); // [{field: 'title', message: 'is too short'}]
38 </code></pre>
40 Ext.define('Ext.data.Errors', {
41 extend: 'Ext.util.MixedCollection',
43 <span id='Ext-data-Errors-method-isValid'> /**
44 </span> * Returns true if there are no errors in the collection
48 return this.length === 0;
51 <span id='Ext-data-Errors-method-getByField'> /**
52 </span> * Returns all of the errors for the given field
53 * @param {String} fieldName The field to get errors for
54 * @return {Object[]} All errors for the given field
56 getByField: function(fieldName) {
60 for (i = 0; i < this.length; i++) {
61 error = this.items[i];
63 if (error.field == fieldName) {