-
12 Sep 2012 2:05 AM #1
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.
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; }
might be better.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; }
-
12 Sep 2012 10:23 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
Thanks for the report! I have opened a bug in our bug tracker.
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.


Reply With Quote