Chapter 14: Creating Custom Validators; Validating Data By Using Custom Validators - Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual

Creating and extending flex 2 components
Hide thumbs Also See for FLEX 2 - CREATING AND EXTENDING COMPONENTS:
Table of Contents

Advertisement

CHAPTER 14
1 4
Creating Custom Validators
Data validators let you validate the data in an object. Adobe Flex supplies a number of
standard validators that you can use in your application, however, you can also define custom
validators for your specific application needs. This topic describes how to create custom
validators.
For information on the standard validators, see Chapter 40, "Validating Data," in Flex 2
Developer's Guide.
Contents

Validating data by using custom validators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217

Example: Validating multiple fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .222
Validating data by using custom
validators
The data that a user enters in a user interface might or might not be appropriate for the
application. In Flex, you use a validator to ensure the values in the fields of an object meet
certain criteria. For example, you can use a validator to ensure that a user enters a valid phone
number value in a TextInput control.
Flex includes a set of validators for common types of user input data, such as ZIP codes,
phone numbers, and credit cards. Although Flex supplies a number of commonly used
validators, your application may require you to create custom validator classes. The
mx.validators.Validator
class is an ActionScript class that you can extend to add your own
validation logic. Your classes could extend the functionality of an existing validator class, or
you could implement new functionality in your custom validator class.
217

Advertisement

Table of Contents
loading

Table of Contents