References: * https://stackoverflow.com/questions/50214195/validating-a-subset-of-list-items-using-java-hibernate-aquiring-the-full-proper * https://discourse.hibernate.org/t/how-can-i-retrieve-current-validation-contexts-groups-in-a-validator/414/4
This was requested by different users 2 times in a row so it's definitely something that could be useful. Currently, we have a workaround by using a {{DefaultGroupSequenceProvider}} but a more natural way to do it would be welcome.
We should be able to: * decide if we trigger the validation for the/one of the cascaded object(s) depending on the cascaded object itself: not sure this would be easy as you could have a container, in which case you should consider each element of the container (we would probably need to add the annotation at the container level). * decide if we trigger the cascading entirely depending on the cascading object.
Something like: {code} class CascadingObject { @Valid // probably would be the default in this case. @ CascadingObjectCondition ValidPredicate ( target = CASCADING_OBJECT, value = MyPredicateOnCascadingObject.class) private CascadedObject cascadedObject; {code}
{code} class CascadingObject { @Valid @ CascadedObjectCondition ValidPredicate ( target = CASCADED_OBJECT, value = MyPredicateOnCascadedObject.class) private CascadedObject cascadedObject; {code}
{code} class CascadingObject { @Valid // no need to define the target as in this case, there's no doubt about the target private List<@ CascadedObjectCondition Valid @ValidPredicate (MyPredicateOnCascadedObject.class) CascadedObject> cascadedObject; {code}
The names are terrible so part of the challenge is to find good names for this feature We could think about specifying it later and have : ) {code} @Valid(predicate = { @ValidPredicate(MyPredicateOnCascadingObject . class) }) {code} |
|