Adobe FLEX 2 - CREATING AND EXTENDING COMPONENTS Manual page 218

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

Advertisement

The following image shows the class hierarchy for validators:
Validator
All validator classes
About overriding the doValidation() method
Your custom validator class must contain an override of the protected
method that takes a single argument,
of type Object,
Validator.doValidation()
value,
and returns an Array of ValidationResult objects. You return one ValidationResult object for
each field that the validator examines and fails the validation. For fields that pass the
validation, you omit the ValidationResult object.
You do not have to create a ValidationResult object for fields that validate successfully. Flex
creates those ValidationResult objects for you.
The base Validator class implements the logic to handle required fields by using the
required
property. When set to
, this property specifies that a missing or empty value in a user-
true
interface control causes a validation error. To disable this verification, set this property to
.
false
In the
method of your validator class, you typically call the base class's
doValidation()
method to perform the verification for a required field. If the user did not
doValidation()
enter a value, the base class issues a validation error stating that the field is required.
The remainder of the
method contains your custom validation logic.
doValidation()
About the ValidationResult class
The
method returns an Array of
ValidationResult
objects, one for each field
doValidation()
that generates a validation error. The ValidationResult class defines several properties that let
you record information about any validation failures, including the following:
A String that contains an error code. You can define your own error codes for
errorCode
your custom validators.
A String that contains the error message. You can define your own error
errorMessage
messages for your custom validators.
A Boolean value that indicates whether or not the result is an error. Set this property
isError
to
.
true
218
Creating Custom Validators

Advertisement

Table of Contents
loading

Table of Contents