Support groups translation during cascaded validations

Description

Cascaded validation via @Valid should allow to transform validated groups when traversing from one object to the other. Something like:

Environment

None

Activity

Show:
Hardy Ferentschik
April 3, 2012, 5:10 PM

I think @MethodValidated is a different beast. I lets @Valid and constraint declarations intact. I guess I am most worried about modifying @Valid.

Emmanuel Bernard
April 3, 2012, 6:23 PM

I agree with this concern. I think that if we bring this group translation idea to fruition, it is going to be a dedicated annotation. @ConverGroup(from=Foo.clas, to=Bar.class)

Hardy Ferentschik
April 3, 2012, 6:26 PM

I agree with this concern. I think that if we bring this group translation idea to fruition, it is going to be a dedicated annotation. @ConverGroup(from=Foo.clas, to=Bar.class)

+1

val
August 16, 2012, 2:27 AM

+1 For this feature, I have run up against this problem multiple times already.

The simplest usecase I can come up with is a wizard like flow building up a credit card payment details bean, which may have two addresses shipping and billing. Step one you want to validate the shipping address, step two you need to validate the billing address.

@Entity
public class PaymentDetails{

@Embeded
@Valid(groups={IContactForm.class})
Address address;

@Embedded
@Valid(groups={IBillingForm.class})
@AttributeOverrides({@AttributeOverride(name="address1", column=@Column(name="billing_address1")), ..., ...., })
Address billingAddress;

}

Hardy Ferentschik
August 30, 2012, 3:11 PM

Some thoughts on group sequence resolution (correct me from wrong):

  • the group execution order defined by the groups and groups sequences passed to the Validator#validate can still be resolved statically (as it is done now). There is no need to know anything about group translations or default group redefinitions

  • a group transformation via @ConvertGroup (or whatever we are going to name this annotation) behaves similar to a redefined default group sequence. Effectively when the group translation is encountered a 'sub' validate call needs to be executed with the current bean as validated object and the translated groups as group parameters

Fixed

Assignee

Emmanuel Bernard

Reporter

Marc Schipperheyn

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Fix versions

Affects versions

Priority

Major
Configure