-->
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: Question about Bean Validation 1.1
PostPosted: Thu Jun 22, 2017 12:20 pm 
Newbie

Joined: Thu Jun 22, 2017 11:56 am
Posts: 1
Hello,

I want to use the same POJO with 3 fields (field1, field2, field3) for 2 REST calls.
For the first REST call, I want to check that one of the 3 fields are not null and the 2 other ones are null.
For the second REST call, I want to check that at least one of the 3 fields is not null.

How to achieve that with Java Bean Validation 1.1 ?
I want to use Java Bean Validation group feature but what I don't get is that I can't use something like @Valid(group="mygroup") !
But programmatically, I can perform the following operation: validator.validate(myobject, "mygroup") !!!

Could someone help me to solve this issue ?

Best Regards.


Top
 Profile  
 
 Post subject: Re: Question about Bean Validation 1.1
PostPosted: Tue Jun 27, 2017 11:13 am 
Hibernate Team
Hibernate Team

Joined: Sat Jan 24, 2009 12:46 pm
Posts: 388
I would recommend to use a dedicated POJO/DTO for each of the two services. If that's not viable, take a look at group conversion:

Code:
public void service1(@Valid @ConvertGroup(from=Default.class, to=Group1.class) MyDto dto) { ... }

public void service2(@Valid @ConvertGroup(from=Default.class, to=Group2.class) MyDto dto) { ... }

_________________
Visit my blog at http://musingsofaprogrammingaddict.blogspot.com/


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.