[bv-dev] Method validation - cont'd

Emmanuel Bernard emmanuel at hibernate.org
Tue May 15 04:56:53 EDT 2012


On 14 mai 2012, at 14:53, Hardy Ferentschik wrote:

>> 
>> * Should method validation methods be defined on j.v.Validator or a
>> dedicated new interface?
> 
> Should be on javax.validation.Validator

I still think my proposal is quite elegant and limit duplication

> public interface Validator {
>     MethodValidator<T> forMethod(Method method, T object);
>     MethodValidator<T> forConstructor(Constructor<T> constructor);
> }
> 
> public interface MethodValidator<T> {
>     <T> Set<MethodConstraintViolation<T>> validateParameter(
>         Object parameterValue, int parameterIndex, Class<?>... groups);
> 
>     <T> Set<MethodConstraintViolation<T>> validateAllParameters(
>         Object[] parameterValues, Class<?>... groups);
> 
>     <T> Set<MethodConstraintViolation<T>> validateReturnValue(
>         Object returnValue, Class<?>... groups);
> }


http://beanvalidation.org/proposals/BVAL-241/#validating




More information about the beanvalidation-dev mailing list