Validators - Adobe FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual

Migrating applications to flex 2
Table of Contents

Advertisement

Validators

In Flex 1.5, validators were usually triggered in response to an update of the destination of a
data binding expression. You typically assigned the validator to the destination of a data
binding expression, and triggered the validation when the destination of the data binding
expression was updated, as the following example shows:
<!-- Define a data model for storing the phone number. -->
<mx:Model id="userInfo">
<phoneNum>{phoneInput.text}</phoneNum>
</mx:Model>
<!-- Define the PhoneNumberValidator. -->
<mx:PhoneNumberValidator field="userInfo.phoneNum"/>
<!-- Define the TextInput control for entering the phone number. -->
<mx:TextInput id="phoneInput"/>
In Flex 2, validators are triggered by default by the
binding to assign it to the interface control rather than to a model. The source property
specifies the name of the control, and the
to validate, as the following example shows:
<!-- Define the PhoneNumberValidator. -->
<mx:PhoneNumberValidator id="pnV" source="{phoneInput}" property="text" />
<!-- Define the TextInput control for entering the phone number. -->
<mx:TextInput id="phoneInput"/>
You can also use the
validate()
programmatically. All validator classes now include a
CreaditCardValidator constants moved to a new class
The constants that define the type of credit card to validate were moved from the
CreditCardValidator class to a new class named CreditCardValidatorCardType.
The constants were also renamed. In MXML, valid constants values are:
"American Express"
"Diners Club"
"Discover"
"MasterCard"
"Visa"
170
Additional Migration Issues
valueCommit
property specifies the field of the control
property
method of the validator to trigger a validator
validate()
event, and you use data
method.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flex 2

Table of Contents