Macromedia flex 2 Manuale

Pagina di 254
Example: Creating a simple validator
219
subField
A String that specifies the name of the subfield associated with the 
ValidationResult object. 
In your override of the 
doValidation()
 method, you can define an empty Array and 
populate it with ValidationResult objects as your validator encounters errors.
About the validate() method
You use the 
Validator.validate()
 method to programmatically invoke a validator from 
within a Flex application. However, you should never override this method in your custom 
validator classes. You need to override only the 
doValidation()
 method.
Example: Creating a simple validator
You can use the 
StringValidator
 class to validate that a string is longer than a minimum length 
and shorter than a maximum length, but you cannot use it to validate the contents of a string. 
This example creates a simple validator class that determines if a person is more than 18 years 
old based on their year of birth.