> 
> Too sad, that javax.validation.ValidatorContext is not defined as
> 
> public interface ValidatorContext <V extends ValidatorContext<V>> {
> 
> }
> 
> If it were, we wouldn't need a dedicated method 
> HibernateValidatorFactory#usingHibernateContext(), but 
> HibernateValidatorFactory could be defined as
> 
> public interface HibernateValidatorFactory extends ValidatorFactory {
> 
>     HibernateValidatorContext usingContext();   
>     
> }
> 
> then, allowing the validator to be retrieved like that:
> 
> failFastValidator =
>                 factory.unwrap(HibernateValidatorFactory.class)
>                     .usingContext()
>                         .maxConstraintViolationCount(5)
>                     .getValidator();
> 

Yes I've hesitated back in the days and thought unwrap was enough :(
I wonder if we can retroactively enhance it without breaking clients.

> note that we can also envision something like
> 
> ailFastValidator = regularValidator.unwrap(HibernateValidatorFactory.class)
>                                        .usingHibernateContext()
>                                                .failFast(true)
>                                        .getValidator();
> 
> I don't quite understand this approach, you want to unwrap a validator into a 
> validator factory? Or do you think of re-configuring a once retrieved 
> validator? Retrieving a new validator from an existing one seems akward to me.

The former: unwrap a ValidatorFactory out of an existing Validator without 
changing the existing validator behavior.
_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to