Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJSIV-7226 in 4.1.3 Sprint 1.
  1. #1
    Sencha User mono blaine's Avatar
    Join Date
    Jul 2008
    Location
    Turkey
    Posts
    120
    Vote Rating
    7
    mono blaine will become famous soon enough

      0  

    Default Presence validation does not take boolean values into account

    Presence validation does not take boolean values into account


    The implementation of Ext.data.validations.presence returns incorrect results when a boolean model field is considered.

    Code:
    /**
     * Validates that the given value is present.
     * For example:
     *
     *     validations: [{type: 'presence', field: 'age'}]
     *
     * @param {Object} config Config object
     * @param {Object} value The value to validate
     * @return {Boolean} True if validation passed
     */
    presence: function (config, value) {
        // No configs read, so allow just value to be passed
        if (arguments.length === 1) {
            value = config;
        }
    
        //we need an additional check for zero here because zero is an acceptable form of present data
        return !!value || value === 0;
    }
    Therefore the presence validation of a false value returns false (it should be true instead) in this case.

    Code:
    /**
     * Validates that the given value is present.
     * For example:
     *
     *     validations: [{type: 'presence', field: 'age'}]
     *
     * @param {Object} config Config object
     * @param {Object} value The value to validate
     * @return {Boolean} True if validation passed
     */
    presence: function (config, value) {
        // No configs read, so allow just value to be passed
        if (arguments.length === 1) {
            value = config;
        }
    
        //we need an additional check for zero here because zero is an acceptable form of present data
         return !!value || value === 0 || value === false;
    }
    might be better.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,599
    Vote Rating
    434
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.