0

I was referring to:

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:

@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:

strValid followed by Cvalidator followed by BValidator followed by AValidator (basically member validations to run before class validations and this rule being applied recursively)

Really appreciate your help.

Community
  • 1
  • 1

0 Answers0