Validators
From http://www.adobe.com/devnet/flex/quickstart/validating_data/:
The data that a user enters in a user interface control might or might not be appropriate for the application. In Adobe Flex applications, you use a validator to ensure the values in the fields of a form meet certain criteria. For example, you can use a validator to ensure that a user enters a valid phone number value, to ensure that a String value is longer than a set minimum length, or ensure that a ZIP code field contains the correct number of digits.
Included Validators in the mx.validators package:
- StringValidator - validates input as a string
- RegExpValidator - validates input against a regular expression
- NumberValiator - validates input is a number
- EmailValidator - validates input is in valid email address format
- Date Validator - validates input is in valid date format
- ZipCodeValidator - validates input is in zip code format
- CurrencyValidator - validates input is a valid currency expression
- PhoneNumberValidator - validates input is in valid phone number format
- CreditCardValidator - validates input is in valid credit card format
Calling a Validator in ActionScript:
import mx.validators.*; var validationEvent:ValidationResultEvent = validator.validate(); // the validation result event's type signals valid or not if( validationEvent.type == ValidationResultEvent.VALID ) { // valid, success! } else { // not valid, do something with validationEvent.results items } // the validation result event's results array is empty if valid if( validationEvent.results.length == 0 ) { // valid, success! } else { // not valid, do something with validationEvent.results items }

