[hibernate-dev] [Bean Validation] Type-safe Validator and resolution algorithm

Hardy Ferentschik hibernate at ferentschik.de
Sun Jan 25 09:27:26 EST 2009


Hi,

I think the proposed feature is in line with the overall design principles  
of Bean Validaton.
Given how much effort was put onto making the API as typesafe as possible  
it seems natural to
do the same for isValid().


> I would really like feedback on it as we could arrange some of these
> rules to not fail (at least in the latter case):
>   - do we want this type-safe + auto resolution algorithm strategy or
> should we stick with the untyped solution

+1 for typesafe.

>   - do we want to fail in case of ambiguity or rather choose the first
> compatible provider?

+1 for fail on ambiguity


> @Constraint(validatedBy={
>      StringSizeValidator.class, CollectionSizeValidator.class,
>      MapSizeValidator.class, ArraySizeValidator.class} )
> public @interface Size { ... }

I agree with Sanne's comment here:

> I am not liking the flexibility to have several different
> implementations associated to the same annotation;
> IMHO using a 1-1 should be more clear to the user which validation
> implementation he is going to use.

A 1-1 mapping seems to be more natural. It also will remove general  
ambiguity.


--Hardy




More information about the hibernate-dev mailing list