Structure of validation.xml
4.1. validation.xml The key to enable XML configuration for Hibernate Validator is the file validation.xml. If this file exists in the classpath its configuration will be applied when the ValidationFactory gets created. Example 4.1, “validation-configuration-1.0.xsd” shows a model view of the xsd valiation.xml has to adhere to. Example 4.1. validation-configuration-1.0.xsd Example 4.2, “validation.xml” shows the several configuration options of validation.xml. Example 4.2. validation.xml org.hibernate.validator.HibernateValidator org.hibernate.validator.engine.ResourceBundleMessageInterpolator org.hibernate.validator.engine.resolver.DefaultTraversableResolver org.hibernate.validator.engine.ConstraintValidatorFactoryImpl /constraints-car.xml value1 value2 Warning There can only be one validation.xml in the classpath. If more than one is found an exception is thrown. All settings shown in the validation.xml are optional and in the case of Example 4.2, “validation.xml” show the defaults used within Hibernate Validator. The node default-provider allows to choose the Bean Validation provider. This is useful if there is more than one provider in the classpath. message-interpolator, traversable-resolver and constraint-validator-factory allow to customize the javax.validation.MessageInterpolator, javax.validation.TraversableResolver resp. javax.validation.ConstraintValidatorFactory. The same configuration options are also available programmatically through the javax.validation.Configuration. In fact XML configuration will be overridden by values explicitly specified via the API. It is even possible to ignore the XML configuration completely via Configuration.ignoreXmlConfiguration(). See also Chapter 5, Bootstrapping. Via the constraint-mapping you can list an arbitrary number of additional XML files containing the actual constraint configuration. See Section 4.2, “Mapping constraints”. Last but not least, you can specify provider specific properties via the property nodes. Hibernate Validator does currently not make use of any custom properties.