RE: [flexcoders] Re: Custom Validator woes....

2006-06-28 Thread Jason Szeto










Susan,

 

    The
reason that it is not static is because most validators have properties that
help define the validation rules. For example, the Number validator has a maxValue
and minValue property. Also, you can customize the error messages for each
validator. Thus, we need instances of the validators to accomplish this.

 

As for the “errorString”
property, it is better to use the UIComponent.validationResultHandler function
instead. Just pass in the results from the validate() function. 

 

Jason

 









From:
flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Suzy Lawson
Sent: Wednesday, June 28, 2006
6:25 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Custom
Validator woes



 







Jason,
Thanks. I guess I just got mixed up since it's a little unnatural to
instantiate a class to call a method that should be static! Also,
adding text to the "errorString" field automatically sets everything
redhere's my method should anyone search upon this message at a
future date:

private function validateField() : void {
var emails : Array = toField.text.split(",");
for(var j:uint=0; j < emails.length; j++)
{
var emailVal : EmailValidator = new EmailValidator();
var valResult : ValidationResultEvent =
emailVal.validate(emails[j]);
if(valResult.type == ValidationResultEvent.INVALID)
{
toField.errorString="'" + emails[j] + "' is not a valid
e-mail address.";
return;
}
}
}

--- In [EMAIL PROTECTED]ups.com,
"Jason Szeto" <[EMAIL PROTECTED]> wrote:
>
> Suzy,
> 
> 
> 
> The listener, source and trigger are all optional properties
> of Validators. You can just call the validate() function. Pass in the
> string you want to validate and it will return the ValidationResult. The
> validate() function is on the base class, Validator. 
> 
> 
> 
> Jason
> 
> 
> 
> 
> 
> From: [EMAIL PROTECTED]ups.com
[mailto:[EMAIL PROTECTED]ups.com]
On
> Behalf Of Suzy Lawson
> Sent: Tuesday, June 27, 2006 10:54 AM
> To: [EMAIL PROTECTED]ups.com
> Subject: [flexcoders] Custom Validator woes
> 
> 
> 
> I'm building an e-mail client where the "To:" field can have a
comma
> delimited array of e-mail addresses: "[EMAIL PROTECTED]
> 40yahoo.com> , [EMAIL PROTECTED] 40yahoo.com>
"
> 
> I have the validation occuring in the focusOut event, where I split
> the "To:" field so I get an Array of e-mail addresses. 
> var emails : Array = value.split(",");
> 
> I then want to loop through and validate each value. However, there is
> no easy way to do this using the Flex SDK EmailValidator.as.
> 
> Ideally, I would think I could call a static method which would return
> me a ValidationResultEvent, which I could then add to my component.
> However, everything with the SDK EmailValidator class requires a
> listener/source/trigger to be bound to it and no matter what I try to
> doit looks at that "To:" field as one big String...I can't
give it
> just the iterated split value. 
> 
> Any ideas on this?? Is there a way to statically call a method without
> having to pass in a reference to the EmailValidator object?
>






__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___






[flexcoders] Re: Custom Validator woes....

2006-06-28 Thread Suzy Lawson
Jason,
 Thanks. I guess I just got mixed up since it's a little unnatural to
instantiate a class to call a method that should be static! Also,
adding text to the "errorString" field automatically sets everything
redhere's my method should anyone search upon this message at a
future date:

private function validateField() : void {
var emails : Array = toField.text.split(",");
for(var j:uint=0; j < emails.length; j++)
{
   var emailVal : EmailValidator = new EmailValidator();
   var valResult : ValidationResultEvent =
emailVal.validate(emails[j]);
   if(valResult.type == ValidationResultEvent.INVALID)
   {
  toField.errorString="'" + emails[j] + "' is not a valid
e-mail address.";
  return;
   }
}
}

--- In flexcoders@yahoogroups.com, "Jason Szeto" <[EMAIL PROTECTED]> wrote:
>
> Suzy,
> 
>  
> 
> The listener, source and trigger are all optional properties
> of Validators. You can just call the validate() function. Pass in the
> string you want to validate and it will return the ValidationResult. The
> validate() function is on the base class, Validator. 
> 
>  
> 
> Jason
> 
>  
> 
> 
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Suzy Lawson
> Sent: Tuesday, June 27, 2006 10:54 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Custom Validator woes
> 
>  
> 
> I'm building an e-mail client where the "To:" field can have a comma
> delimited array of e-mail addresses: "[EMAIL PROTECTED]
>  , [EMAIL PROTECTED]  "
> 
> I have the validation occuring in the focusOut event, where I split
> the "To:" field so I get an Array of e-mail addresses. 
> var emails : Array = value.split(",");
> 
> I then want to loop through and validate each value. However, there is
> no easy way to do this using the Flex SDK EmailValidator.as.
> 
> Ideally, I would think I could call a static method which would return
> me a ValidationResultEvent, which I could then add to my component.
> However, everything with the SDK EmailValidator class requires a
> listener/source/trigger to be bound to it and no matter what I try to
> doit looks at that "To:" field as one big String...I can't give it
> just the iterated split value. 
> 
> Any ideas on this?? Is there a way to statically call a method without
> having to pass in a reference to the EmailValidator object?
>







 Yahoo! Groups Sponsor ~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM
~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/