Thanks, Emmanuel
Here is a use case right
off from my current work. My system is monitoring a set of devices. A
device is modeled as a class named AuthorizedDevice. This class has many
attributes. One of them is 'model' which can be any value from a set of
valid values: SD, TRANSNET, X710... An AuthorizedDevice also has an
attribute called 'role' which can be either REMOTE or ACCESSPOINT. Based
on the value set for 'model' & 'role', we either do or relax
specific constraints on some attributes. For example: if an
AuthorizedDevice has its 'role' set to ACCESSPOINT, we require certain
attributes must not be blank. While an AuthorizedDevice has its 'role'
set to REMOTE, we relax certain constraints.
I've tried to use grouping feature of Bean Validation but it
doesn't seem to help in achieving the my goal. I agree we can always
write custom constraints but that means I can't reuse the built-in
validation constraints from the framework (not even in the case of
writing a constraint composition). And certainly, I would not want to
write a custom constraints for checking NotBlank. @ScriptAssert is no
better than writing your own custom constraint.
Thang