[bv-dev] Constraint on non generic types (was Re: Support for constraints on container values (e.g. Collection<@Email String>))

Emmanuel Bernard emmanuel at hibernate.org
Tue Nov 22 08:13:56 EST 2016


On Tue 16-11-22 12:36, Gunnar Morling wrote:
>Just replying to this one:
>
>> == Constraint on non parameterized containers
>> I am liking option 3 less and less and as far as I can remember, it does
>not rely on an explicitly
>> identified use case. Who is wanting to support that usage, vs restrict
>the container feature to
>> parameterized containers?
>
>I'm not sure where this requirement is coming from. Wouldn't it simply be
>addressed by providing a validator for @Min + IntegerContainer? I.e. do we
>need any explicit support for this at all compared to what's possible today?

The big thing you lose by know understanding the notion of container is
that validation won't be cascaded to objects in the container.

@Valid AddressContainer

This is close to impossible to reproduce by hand.

>Also the JavaFX case (your 2nd example around StringProperty) could be
>satisfied by just adding explicit validators for StringProperty,
>IntegerProperty etc. Agreed it's not as elegant/generic and wouldn't work
>for custom types. May still be a way forward, though.

No, you can't do that. Unless you accept that @MyEmail constraint cannot
be applied on a StringProperty. That's a big blocker for me.


More information about the beanvalidation-dev mailing list