Should the presence of type argument constraints alone trigger
cascaded validation E.g. consider the case of Tuple:
class Tuple<T1,T2> {
@NotNull T1 getT1();
@Min(3) getSize();
// ...
}
When validating
class TupleUser {
Tuple<@Min(1) Integer, @Email String> tuple;
}
should this trigger cascaded validation of "tuple", i.e. validation of
@NotNull and @Min within the Tuple class itself?
A variation of the issue is
Map<AddressType, @NotNull Address> myMap;
where validation of "myMap" would cause validation of @NotNull for the
map values, but should it also cause validation of constraints
declared on Address?
Currently, the sole presence of type argument constraints would not
trigger such cascaded validation. You'll need to put @Valid in place
to do so:
@Valid
Tuple<@Min(1) Integer, @Email String> tuple;
Map<AddressType, @NotNull @Valid Address> myMap;
I found such implicit cascaded validation semi-attractive at some
point, but since then have come to think that requiring @Valid is the
better alternative, as it's more consistent with the 1.1 behaviour.
I *think* Matt and Emmanuel support that @Valid should be required
(but confirmation would be nice). What do others think?
--Gunnar