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