You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Ginn, Timothy D Mr CTR USA TRADOC USAAC" <TI...@USAAC.ARMY.MIL> on 2009/08/28 21:16:21 UTC

[U] Email Validation Issue

UNCLASSIFIED////


I have run into a bump in the road.  I am trying to validate a list of
Strings that contain email addresses.  I can't seem to get it to check
the emails to be a valid email using the annotation validation. 

Could someone please let me know if this is possible or if I am doing
something wrong 

    @Validations(
        requiredStrings = {@RequiredStringValidator(message = "At Least
one email address is required.", trim = true)},
        emails = {@EmailValidator(message = "Please enter a valid email
address.", type = ValidatorType.FIELD)}
    )
    public void setLdapAdmins(List<String> ldapAdmins) {
        this.ldapAdmins = ldapAdmins;
    }

ldapAdmins is a list of Strings that contain email addresses. I need to
validate that they are truly email addresses and that the fields are not
"".

Thank you


Tim


UNCLASSIFIED////


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [U] Email Validation Issue

Posted by Norris Shelton <no...@yahoo.com>.
I wrote one that appears to work.  I copied the contents of TegexFieldValidator to get it to work.  Is there a need for more of the validators to support collections?   



 
Norris Shelton
Software Engineer
Sun Certified Java 1.1 Programmer
Shelton Consulting, LLC
ICQ# 26487421
AIM NorrisEShelton
YIM norrisshelton




________________________________
From: Dave Newton <ne...@yahoo.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Friday, August 28, 2009 6:19:45 PM
Subject: Re: [U] Email Validation Issue

Ginn, Timothy D Mr CTR USA TRADOC USAAC wrote:
> I have run into a bump in the road.  I am trying to validate a list of
> Strings that contain email addresses.  I can't seem to get it to check
> the emails to be a valid email using the annotation validation. 
> Could someone please let me know if this is possible or if I am doing
> something wrong 
>    @Validations(
>        requiredStrings = {@RequiredStringValidator(message = "At Least
> one email address is required.", trim = true)},
>        emails = {@EmailValidator(message = "Please enter a valid email
> address.", type = ValidatorType.FIELD)}
>    )
>    public void setLdapAdmins(List<String> ldapAdmins) {
>        this.ldapAdmins = ldapAdmins;
>    }
> 
> ldapAdmins is a list of Strings that contain email addresses. I need to
> validate that they are truly email addresses and that the fields are not
> "".

AFAIK the validations will validate only a single object; I believe you'd need custom validation either via a validate() method, custom validator, etc.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


      

Re: [U] Email Validation Issue

Posted by Dave Newton <ne...@yahoo.com>.
Ginn, Timothy D Mr CTR USA TRADOC USAAC wrote:
> I have run into a bump in the road.  I am trying to validate a list of
> Strings that contain email addresses.  I can't seem to get it to check
> the emails to be a valid email using the annotation validation. 
> 
> Could someone please let me know if this is possible or if I am doing
> something wrong 
> 
>     @Validations(
>         requiredStrings = {@RequiredStringValidator(message = "At Least
> one email address is required.", trim = true)},
>         emails = {@EmailValidator(message = "Please enter a valid email
> address.", type = ValidatorType.FIELD)}
>     )
>     public void setLdapAdmins(List<String> ldapAdmins) {
>         this.ldapAdmins = ldapAdmins;
>     }
> 
> ldapAdmins is a list of Strings that contain email addresses. I need to
> validate that they are truly email addresses and that the fields are not
> "".

AFAIK the validations will validate only a single object; I believe 
you'd need custom validation either via a validate() method, custom 
validator, etc.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org