Sha256: d96b63a4ae02ee0a9db277591365c58d72dd70abfaf65aa24a3b9d4fe3bb600a

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

/**
 * @author Ed Spencer
 * @class Ext.data.Errors
 *
 * <p>Wraps a collection of validation error responses and provides convenient functions for
 * accessing and errors for specific fields.</p>
 *
 * <p>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:</p>
 *
<pre><code>
//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'}]
</code></pre>
 */
Ext.define('Ext.data.Errors', {
    extend: 'Ext.util.MixedCollection',

    /**
     * Returns true if there are no errors in the collection
     * @return {Boolean}
     */
    isValid: function() {
        return this.length === 0;
    },

    /**
     * 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, field, i;

        for (i = 0; i < this.length; i++) {
            error = this.items[i];

            if (error.field == fieldName) {
                errors.push(error);
            }
        }

        return errors;
    }
});

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
gb_mapfish_appserver-0.0.5 vendor/assets/javascripts/ext/ext-4.1.1a/src/data/Errors.js
gb_mapfish_appserver-0.0.4 vendor/assets/javascripts/ext/ext-4.1.1a/src/data/Errors.js
gb_mapfish_appserver-0.0.3 vendor/assets/javascripts/ext/ext-4.1.1a/src/data/Errors.js
gb_mapfish_appserver-0.0.2 vendor/assets/javascripts/ext/ext-4.1.1a/src/data/Errors.js
gb_mapfish_appserver-0.0.1 vendor/assets/javascripts/ext/ext-4.1.1a/src/data/Errors.js
extjs-rails-4.1.0.alpha5 app/assets/javascripts/src/data/Errors.js
extjs-rails-4.1.0.alpha4 app/assets/javascripts/extjs-rails/src/data/Errors.js
extjs-rails-4.1.0.alpha3 app/assets/javascripts/extjs-rails/src/data/Errors.js
extjs-rails-4.1.0.alpha2 app/assets/javascripts/extjs-rails/src/data/Errors.js
extjs-rails-4.1.0.alpha1 app/assets/javascripts/extjs-rails/src/data/Errors.js