-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hibernate-validator @Email annotation
PostPosted: Thu Aug 19, 2010 3:44 pm 
Newbie

Joined: Thu Aug 19, 2010 3:36 pm
Posts: 3
Hi,

I am using hibernate-validation 4.0.2.GA and specifically the @Email validation annotation. It seems like it only checks to make sure that there is an @ sign not whether there is a ".com or .edu etc...". Am I doing something wrong or maybe there is more information I need to give this tag?

Code:
   @Email(message = "{user.emailaddress.valid}")
   public String getEmail() {
      return emailaddress;
   }


Eg.,
myemail@myemail passes vaidation.


Top
 Profile  
 
 Post subject: Re: hibernate-validator @Email annotation
PostPosted: Fri Aug 20, 2010 5:42 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hello,
actually myemail@myemail is a valid email according to the specification: http://www.ietf.org/rfc/rfc0822.txt?number=822.
To be honest, I was surprised too, but in several organisations this format is used for internal emails.

In case you'd like to have some fun with a regular expression, be warned: http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html

If you really want to make sure there's a final prefix, couple @Email with a @Pattern, but be aware that you're going to refuse valid emails.

Also I liked very much what is said here:
Quote:
Don't go overboard in trying to eliminate invalid email addresses with your regular expression. If you have to accept .museum domains, allowing any 6-letter top level domain is often better than spelling out a list of all current domains. The reason is that you don't really know whether an address is valid until you try to send an email to it. And even that might not be enough. Even if the email arrives in a mailbox, that doesn't mean somebody still reads that mailbox.


As a final note, this is the hibernate core forum area, comments about the validator should be posted here

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.