Custom ValidatorFactory to BeanValidator

Hi,

I have a similar need as decribed in this open issue from 2013: https://github.com/vaadin/framework/issues/4362

BeanValidator is currently using javax.validation.ValidatorFactory returned by javax.validation.Validation.buildDefaultValidatorFactory() and I haven’t found a way to affect the configuration of the ValidationFactory that is returned by that call. Am I missing something? Configuring a ValidationFactory is not the issue here, but to get BeanValidator to use the configured factory. I’m sure someone has had this issue before.

Using Spring, Hibernate, Vaadin for what its worth

Anwering to myself and others who might be having same kind of needs: yes I was missing something :slight_smile:

I was stuck in the idea that I would have to do the configuration programmatically, e.g:


ValidatorFactory validatorFactory = Validation.byDefaultProvider()
.configure()
.messageInterpolator( new MyMessageInterpolator() ) .buildValidatorFactory();
Validator validator = validatorFactory.getValidator();

Solution was simply to use validation.xml for configuration and provide the custom MessageInterpolator there:
http://beanvalidation.org/1.1/spec/#xml-config