[hibernate-dev] Introduce a constraint @NoNullElements

Gunnar Morling gunnar.morling at googlemail.com
Sun Apr 25 12:57:16 EDT 2010


Hi,

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.

There is a method noNullElements() in Commons Lang's Validator class, which
I find useful quite often. OTOH this comes at the cost of doing an iteration
over the collection, so people could refrain from using it and check each
element for null themselves when iterating.

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.

Any ideas on that?

Thanks, Gunnar



More information about the hibernate-dev mailing list