-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Add support and test cases for partially honoring OVal's appliesTo field in its constraint annotations.
There are currently 4 distinct ConstraintTarget values, although I don't believe it's necessary to support them all:
ConstraintTarget.VALUES- Apply this constraint to the individual field if it is not a collection, otherwise apply the constraint to the members of the collection themselves.ConstraintTarget.COLLECTION- Apply this constraint to the collection itself.ConstraintTarget.KEYS- Apply this constraint to the keys of ajava.util.Map.ConstraintTarget.RECURSIVE- Apply this constraint recursively to a collection of collections.
I believe support for the first two initially will provide the most value. ConstraintTarget.VALUES is the default for most OVal constraints so we would more closely align to their semantics, and the collection/element ambiguity seems like a common enough occurrence to be avoided.
Motivating example:
// Neither the collections nor its members should be null
// This is the default for NotNull
@NotNull(appliesTo = {ConstraintTarget.VALUES, ConstraintTarget.COLLECTION})
// Should apply to the strings within the collection
// This is the default for Email
@Email(appliesTo = ConstraintTarget.VALUES)
private final Collection<String> _emails;Metadata
Metadata
Assignees
Labels
No labels