I would like to use different validation groups for a method's parameters and its return value. I am trying to Spring's @Validated annotation to achieve this. For example:
public interface UserOperations {
@Validated({ResponseGroup.class})
@Valid
User createUser(@Validated({RequestGroup.class}) @Valid User user);
}
It appears that return value is in fact getting validated against ResponseGroup, however the method argument user is getting validated against both ResponseGroup and RequestGroup. I see why this is happening when I look at: org.springframework.validation.beanvalidation.MethodValidationInterceptor#invoke
Is there an elegant way to apply one validation group to the method argument and different validation group to the return value?