Flex: Composite Validator

This is a quick utility class I came up with that will keep track of a set of Validators and change a bindable property to true if all of the validators it tracks are valid and false if any of the validators is invalid.

I wanted this so I could quickly say something like:

<mx:Button label=”OK” enabled=”{compositeValidator.valid}” />

Here’s how to use it:

<validators:CompositeValidator id=”compositeValidator”>
<validators:validators>
<mx:StringValidator … />
<mx:EmailValidator … />
</validators:validators>
</validators:CompositeValidator>

<mx:Button …. enabled=”{compositeValidator.valid}” />

To get the source just right click on it and select “View Source …”

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

1 Trackbacks

You can leave a trackback using this URL: http://machine501.com/blog/2008/03/05/flex-composite-validator/trackback/

  1. By links for 2009-05-12 | diamondTearz on May 12, 2009 at 4:02 pm

    [...] machine501 » Blog Archive » Flex: Composite Validator (tags: flex validation composite validator) [...]

Post a Comment

Your email is never shared. Required fields are marked *

*
*