On Sun, 25 Apr 2010 18:57:16 +0200, Gunnar Morling
<gunnar.morling(a)googlemail.com> wrote:
I recently thought about adding a constraint @NoNullElements to
Hibernate
Validator. It would apply to iterables/arrays/maps and would ensure,
well, that the annotated collection contains no nulls.
Whether a @NoNullElements would be useful depends a lot on
http://opensource.atlassian.com/projects/hibernate/browse/BVAL-202
As Emmanuel was saying the by far best solution (definitely from the BV
spec point of view) is to
wait for JSR 308. The question is if and what we do in the interim for
Hibernate Validator
(see also
http://opensource.atlassian.com/projects/hibernate/browse/HV-296)
I don't like the idea of using a 'special' group or payload. Leaves the
OnElements idea or
we just provide some additional constraint validator implementations for
Iterables. This would be
some interim solution in which case something like @NoNullElements could
be useful as well.
I also thought about adding some flag to the existing @NotEmpty
constraint, which could enable this check. But @NotEmpty also applies to
strings, for
which such flag would not make sense very much.
Since @NotEmpty also works on string I am against such a flag in this
case. I vaguely remember
a discussion about this on Jira or the forum.
--Hardy