Using SmartGWT 2.4...
I read on another post that DateItem contains an implicit isDate validator. I can verify this by creating a DynamicForm with a DateItem (which itself has a textItem field), entering a bogus string (like "foo"), then calling validate on the DynamicForm. A validation message is shown on the DateItem: "Must be a date.".
If I call setValidators() on the DateItem and provide my own validators, the implicit isDate validator seems to be getting called after my own validators.
If a non-valid date value is entered, the resulting Object passed in to validators is a String type.
In some cases, this is fine. For example, if the DateItem just has a single RequiredValidator, as it doesn't care about the value type as much as it cares that the value is not null.
However, if I want to do other validation where I do want to care that the Object passed in is a date, then having the implicit isDate validator last doesn't make much sense, as I would want to validate that first, then optionally validate the other bits.
Is there a way to disable this implicit validation, and maybe expose it as a Validator sub-class, so that one can optionally control when to run it within the array of validators?
I read on another post that DateItem contains an implicit isDate validator. I can verify this by creating a DynamicForm with a DateItem (which itself has a textItem field), entering a bogus string (like "foo"), then calling validate on the DynamicForm. A validation message is shown on the DateItem: "Must be a date.".
If I call setValidators() on the DateItem and provide my own validators, the implicit isDate validator seems to be getting called after my own validators.
If a non-valid date value is entered, the resulting Object passed in to validators is a String type.
In some cases, this is fine. For example, if the DateItem just has a single RequiredValidator, as it doesn't care about the value type as much as it cares that the value is not null.
However, if I want to do other validation where I do want to care that the Object passed in is a date, then having the implicit isDate validator last doesn't make much sense, as I would want to validate that first, then optionally validate the other bits.
Is there a way to disable this implicit validation, and maybe expose it as a Validator sub-class, so that one can optionally control when to run it within the array of validators?
Comment