Data validation is used to ensure that data meets specific criteria before the application uses it. Flex has a set of Validator classes that can be used to check and make sure that data has been entered correctly. You can use Validator classes either as MXML tags or instantiate them directly in ActionScript. With Flex framework, it is possible to use validators to perform this checking at the client instead of when the data is submitted to the server. This is advantageous because it reduces the amount of data transmitted between the client and the server, which can result in a better-performing application. Of course, some types of secure data validation are best performed at the server, but using Validator classes at the client improve performance by offloading some validation to Flash Player.
All validators subclass the Validator class. Some of the validators available as part of Flex framework include the following:
You often need to perform data validation outside the scope of built-in Validator classes, so Flex enables you to use the functionality of the Validator classes to build your own custom validators. For example, you might want to be sure that a user attaches a valid type of file to be uploaded. Or you might want to display only files to the user that have the word "Flex" in them. By subclassing the Validator classes, you can build a custom validator for any situation that might arise using a minimum of code.
Flex also has a set of Formatter classes that can format raw data into a customized string. You can use the Formatter classes with data binding to automate data binding tasks and be able to apply the formatting to multiple fields simultaneously.
All formatters subclass the Formatter class; some of the formatters available include these: