I understand this problem can easily be fixed by avoiding Flex validators and 
just checking control["text"] != null && control["text"] != "" then 
control.errorString = "This field is required."; but I would like to reuse 
Validators for other scenarios (like email validation) and the same issue pops 
up.

--- In [email protected], "tntomek" <tnto...@...> wrote:
>
> I have a static helper method I call that validates required field.
> 
> var text:TextInput= new TextInput();
> 
> if I run this twice:
> validateRequired(text);
> validateRequired(text);
> 
> My text.errorMessage = "This field is required\nThis field is required"
> 
> I noticed that we keep pushing errorMessage to the private 
> errorObjectArray/errorArray in UIComponenet. What can I do to 'clear' the 
> error state so that errorObjectArray gets flushed accordingly? setting 
> errorString to nul/"" doesnt seem to help as it gets rebuild on the next 
> validate(). Should I remove some eventListeners?
> 
> public static function validateRequired(control:UIComponent) : Boolean
> {
>       control.errorString = "";
>       
>       var reqFieldValidator:Validator = new Validator();
>       reqFieldValidator.source = control;
>       reqFieldValidator.required = true;
>       reqFieldValidator.property = "text";
>       reqFieldValidator.listener = control;
> 
>       return (reqFieldValidator.validate().type != 
> ValidationResultEvent.VALID);
> }
>


Reply via email to