Reputation: 2573
Model
:Ext.define('Web.model.Server', {
extend : 'Ext.data.Model',
idProperty : 'guid',
fields : [ {
name : 'guid',
type : 'string'
},/* ... */ {
name : 'timeout',
type : 'integer'
}],
validators : {
timeout : {
type : 'length',
min : 10,
max : 60
}
}
});
Whenever I set timeout
to any value (such as 40
) and call .isValid()
, it returns false
and says timeout: Length must be between 10 and 60
. In other words, it is validating the value's length as a String
, not the value of the number itself.
I can't find anything in the documentation about validating number's values: the 5.1.1 ext validator docs are not extensively written.
How can I validate the value of the number, instead of its length?
Upvotes: 1
Views: 24
Reputation: 4047
Try using the range validator:
validators: {
timeout: {
type: 'range',
min: 10,
max: 60
}
}
Upvotes: 2