I was referring to:
http://stackoverflow.com/questions/10380209/java-bean-validation-groupsequence-with-class-level-constraint
This works fine for simple classes. But I am working on something as follows:
Class A (validated by AValidator) has a member Class B (validated by BValidator)
has a member Class C(validated by Cvalidator) as well as some primitive members like Strings.
Ideally I would like the string members of Class C to be validated first followed by CValidator followed by BValidator followed by AValidator.
Note: All the classes follow association, they do not have a parent child relationship.
Here is how the code looks like:
Code:
@AType
public class A{
B bmember1;
B bmember2;
}
@Constraint(validatedBy = AValidator.class)
public @interface AType{
//some code
}
@BType
public class B{
C cmember1;
}
@Constraint(validatedBy = BValidator.class)
public @interface BType{
//some code
}
@CType
public class C{
@strvalid
String someString;
}
@Constraint(validatedBy = CValidator.class)
public @interface CType{
//some code
}
So ideally I would want the following execution sequence:
Code:
strValid
followed by
Code:
Cvalidator
followed by
Code:
BValidator
followed by
Code:
AValidator
(basically member validations to run before class validations and this rule being applied recursively)
Really appreciate your help.