What I do when I want two validators on one field is create a third validator and then in its validate method call the other two validators (this is one reason we have those static methods).

 

<mx:Validator field=”myField” validate=”doBothValidators(event.validator)” />

 

<mx:Script>

  Function doBothValidators(validator : Validator) : Void

  {

    StringValidator.validateString(validator, myField, {options…});

    OtherValidator.validate…(…);

  }

</>

 

We are trying to see what we can do to make the validator system a little more developer-friendly in the next release.

 

HTH,

Matt

 


From: Ketan Bengali [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 08, 2005 11:04 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Another on validators

 

Is there any way where in I can have 2 (custom) validators for 1 field.
Lets say, I have written components which can be used for various fields
in a form or many forms spread across the  application(s).

I would want to reuse them instead of copying the same
stuff in diff. validators.

If this cannot be done in current version ofFLEX I think
this feature should be added in the future one.

Also there should be some way to add other field's value
in the validator of a field.
May be one wants to pass different parameters to a validator the way we
pass in Standard validators

In <mx:Validators> tag I cannot add custom properties from .mxml file
similar to standard
validators (minLength, maxLength etc.)

Thanks.

--
Regards,

Ketan Bengali
Multimedia Programmer,
Silver Communication Pvt. Ltd.,
Pune.



Reply via email to