Hi everyone, I would like to see an example of the EmailValidator class.
Can you help me, please?
from [url=http://dev.vaadin.com/svn/versions/6.0/src/com/vaadin/tests/validation/TestValidators.java]
http://dev.vaadin.com/svn/versions/6.0/src/com/vaadin/tests/validation/TestValidators.java
[/url][url=http://dev.vaadin.com/svn/versions/6.0/src/com/vaadin/tests/validation/TestValidators.java]
tf = new TextField( "A field, must contain an e-mail address or be empty");
tf.addValidator(new EmailValidator("Invalid e-mail address {0}"));
tf.setValue("a.b@example.com");
[/url]
If you call tf.validate() you’ll get an InvalidValueException if the mail address in not valid, otherwise nothing will happen.
Regards
Ok!, thanks Guglielmo.
Just for the completeness: If you use JSR 303 validation with hibernate’s implementation, you can annotate your email property with org.hibernate.validator.constraints.Email