PDA

View Full Version : [CLOSED] [4.2.0 GA] Data validations length should return true if undefined/null and max only



Daniil
2 Apr 2013, 4:17 AM
REQUIRED INFORMATION

Ext version tested:

Ext 4.2.0 GA

Browser versions tested against:

Any

DOCTYPE tested against:

Any

Description:

Currently, the Ext.data.validations.length looks:


length: function (config, value) {
if (value === undefined || value === null) {
return false;
}

var length = value.length,
min = config.min,
max = config.max;

if ((min && length < min) || (max && length > max)) {
return false;
} else {
return true;
}
}


If returns false for undefined or null independently on boundaries. But if a developer sets only a max boundary, he is, seems, right to expect true for null or undefined. At least, we can't say that null or undefined exceeds any max boundary.

Test Case:


Please tell me if you really need a test case.


HELPFUL INFORMATION

Possible fix:

We could consider null and undefined as a 0-length value.

Fix

Ext.data.validations.length = function(config, value) {
var length = value ? value.length : 0,
min = config.min,
max = config.max;

if ((min && length < min) || (max && length > max)) {
return false;
} else {
return true;
}
}

mitchellsimoens
2 Apr 2013, 5:39 AM
Thanks for the report! We can take a look at your improvement. I have opened a bug in our bug tracker.