0

I would like to iterate through an object's validators. Validators must be declared in a declarations tag. How does one scroll through declarations? If one cannot, is there a better of locating all validators other than scrolling through all properties of an object?

1
  • 1
    I don't understand the question... Commented Apr 4, 2012 at 4:56

2 Answers 2

2

Just put the Validators in a collection (an Array for instance). After that you can simply loop over the collection's items.

<fx:Declarations>
    <fx:Array id="validators">
        <mx:StringValidator source="{firstnameInput}" property="text" required="true" />
        <mx:StringValidator source="{lastnameInput}" property="text" required="true" />
        <mx:EmailValidator source="{emailInput}" property="text" required="true" />
        <mx:DateValidator source="{dateInput}" property="text" required="false" />
    </fx:Array>
</fx:Declarations>

You can then simply use 'validateAll()':

Validator.validateAll(validators);

or loop over the Validators:

for each (var validator:Validator in validators) { ... }
Sign up to request clarification or add additional context in comments.

Comments

1

I'm not sure if I understand your question correctly, but if you want to iterate over all properties of a class (including meta tags), you can use describeType.

To include meta tags, make sure you've set the appropriate compiler option keep-as3-metadata correctly.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.