[ExtVal] BeanAware constraint validators for Model Validation beanValidation
Hi,
The Constraint Validator for BeanValidation constraints on properties can be
defined in a context repository. The *
BeanValidationModuleValidationInterceptorInternals.validate* method makes
use of code that checks if a bean is defined in a context that can be used.
The *ModelValidationPhaseListener* makes use of a slightly different aproach
which leads to the fact that no beans could be used.
A small change to the ModelValidationPhaseListener.validateTarget method
solves this problem.
I haven't tested the fix extensively but with my small test, I was able to
use a bean for the constraint validator defined on a class.
*ModelValidationPhaseListener.validateTarget*
return ExtValBeanValidationContext.getCurrentInstance()
> .getValidatorFactory().usingContext()
>
> .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
> .getValidator()
> .validate(validationTarget, groups);
>
should become
ValidatorFactory validatorFactory =
> ExtValBeanValidationContext.getCurrentInstance().getValidatorFactory();
> return validatorFactory
> .usingContext()
>
> .messageInterpolator(ExtValBeanValidationContext.getCurrentInstance().getMessageInterpolator())
>
> .constraintValidatorFactory(validatorFactory.getConstraintValidatorFactory())
>
> .traversableResolver(validatorFactory.getTraversableResolver())
> .getValidator()
> .validate(validationTarget, groups);
>
See EXTVAL-86 for the patch.
Include it in the x.x.3 release ?
regards
Rudy.