I've added the following validation.xml configuration file (extracted from the Hibernate Validator reference guide):
Code:
<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration">
<default-provider>org.hibernate.validator.HibernateValidator</default-provider>
<messageinterpolator>
org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator
</messageinterpolator>
<traversable-resolver>
org.hibernate.validator.engine.resolver.DefaultTraversableResolver
</traversable-resolver>
<constraint-validatorfactory>
org.hibernate.validator.engine.ConstraintValidatorFactoryImpl
</constraint-validatorfactory>
</validation-config>
The node default-provider allows to choose the Bean Validation provider. This is useful if there is more than one provider in the classpath
Then, I get a Validator instance in my Controller by doing:
Code:
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
BeanDescriptor descriptor = validator.getConstraintsForClass(ConsultaPedidoEmpForm.class);
I've checked the type of the validator which is "org.hibernate.validator.engine.ValidatorImpl" and when I invoke the validation, it is supposed I should obtain a Set of ConstraintViolation but I only get the Violations for the fields annotated with javax.validation.constraints kind constraints. What about the org.hibernate.validator constraints?? Why the latests aren't recognised for the validator??
Code:
Set<ConstraintViolation<ConsultaPedidoEmpForm>> errors = validator.validate(empForm);
Please, someone who could give me a little clue... I almost have It!