-->
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: Validate Group based in Field Value
PostPosted: Sat Jun 30, 2012 8:37 pm 
Newbie

Joined: Sat May 02, 2009 1:57 pm
Posts: 6
Hey guys,

I was wondering if it was possible to validate a group if a field had a specific value. Something like this:

Code:
public class User
{
   @NotBlank
   public String type;
   
   @NotBlank( group = AdminType.class )
   public String address;
   @NotBlank( group = AdminType.class )
   public String city;
   @NotBlank( group = AdminType.class )
   public String state;
}


And, say, if type == "admin", then I'd like the AdminType.class to be validated along with the default group.

Is something like that possible?

Thanks!

Evan


Top
 Profile  
 
 Post subject: Re: Validate Group based in Field Value
PostPosted: Mon Jul 02, 2012 4:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi Evan,

as per standard Bean Validation this is not possible. You have to call the right groups yourself. Using Hibernate Validator you can use the @GroupSequenceProvider feature. This allows you to redefine the default group of an entity based on its state. Check the online documentation for more information - http://docs.jboss.org/hibernate/validat ... roup-class

--Hardy


Top
 Profile  
 
 Post subject: Re: Validate Group based in Field Value
PostPosted: Mon Jul 02, 2012 8:49 am 
Newbie

Joined: Sat May 02, 2009 1:57 pm
Posts: 6
Hardy,

That looks like it will work for me! Thanks!

E


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.