-->
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.  [ 3 posts ] 
Author Message
 Post subject: Validating an optional URL
PostPosted: Sat Jun 05, 2010 11:58 am 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
Hi,

The @URL validation allows you to validate for a string as a URL. However, in some cases the entered string is optional. If something is entered, it has to validate as an URL, if nothing is entered, it should just pass.

This doesn't seem possible currently. I would suggest adding an attribute required[true|false]

Kind regards,

Marc


Top
 Profile  
 
 Post subject: Re: Validating an optional URL
PostPosted: Sat Jun 05, 2010 12:05 pm 
Pro
Pro

Joined: Wed Nov 05, 2003 7:22 pm
Posts: 211
In fact, it is better that no attribute required is added but that empty strings just pass. A developer can always add a @NotEmpty to ensure content is entered.


Top
 Profile  
 
 Post subject: Re: Validating an optional URL
PostPosted: Mon Jun 07, 2010 5:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
The latest version of Hibernate Validator (4.1.0.Beta2) passes the empty string as valid url - HV-323. No additional parameters required and as you say, if you want to exclude the empty string you add @NotEmpty.

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.