Reputation: 16420
I have some sections in a form which if ticked yes, its sub sections become mandatory.
How Can I do this?
@NotNullIfOtherPropertyNotNull(PropertyName='OtherProperty')
private myProperty;
Upvotes: 0
Views: 155
Reputation: 47954
This is easy to do as a type level constraint. You just create something like
@CascadingNotNull(ifNotNull="otherProperty", thenAlsoNotNull="myProperty")
If you put that on the class, then in your ConstraintHandler you can use whatever flavour of reflect/bean library you like to get the two properties and do the check.
Upvotes: 1