-
27 Jul 2011 1:58 PM #1
Ext 4.0.5 store.sync Presence zero value validation bug
Ext 4.0.5 store.sync Presence zero value validation bug
Situation:
A record that has a model with a int type and gets set to zero will make the record.dirty = true.
store.getUpdatedRecords() returns the updated record and everything is well.
The presence function returns false because !!0 = false although there is a value present
presence: function(config, value) {
if (value === undefined) {
value = config;
}
return !!value; //this should check if value !== 0 because zero is a valid and can be present
},
Now sure how this affects store from synching but it it's. It must be coded not to sync if validation fails.
-
27 Jul 2011 5:27 PM #2
I know Ed fixed this. Let me find out why it didn't make it in.
-
27 Jul 2011 5:47 PM #3Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
This was applied to the 4.1.0 branch. I've just cherry picked it back to 4.0.6 so it will be present in that release. In the mean time you can override it with this patch:
Code:Ext.apply(Ext.data.validations, { presence: function(config, value) { if (value === undefined) { value = config; } //we need an additional check for zero here because zero is an acceptable form of present data return !!value || value === 0; }, /** * Returns true if the given value is between the configured min and max values. * For example: * * validations: [{type: 'length', field: 'name', min: 2}] * * @param {Object} config Config object * @param {String} value The value to validate * @return {Boolean} True if the value passes validation */ 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; } } });Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
28 Jul 2011 6:05 AM #4
4.0.6
4.0.6
When do you expect 4.0.6 to be out? 4.1.0?
-
28 Jul 2011 9:55 AM #5Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Typically patch releases are every 2-3 weeks though we might push this one out sooner
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
27 Mar 2012 4:12 AM #6
validate for presence of boolean values
validate for presence of boolean values
Hi there,
it seems there is quite the same problem with boolean values and validation for presence.
Suggestion:return !!value || value === 0 || value === false;or am i wrong?
regard,
Simon
Thank you for reporting this bug. We will make it our priority to review this report.


Reply With Quote