The javax.validation.constraints
leaves the validators to the implementation. Hibernate provides validators to these constraints, and registers them when bootstrapping.
You can set the validators via XML without using @Constraint(validatedBy = { })
. However, this is usually used to add to/replace the provided validators with your own. I'm not sure how it will help you since you still need to reference the constraint validator.
Example of using XML constraint definition:
<constraint-definition annotation="org.mycompany.CheckCase">
<validated-by include-existing-validators="false">
<value>org.mycompany.CheckCaseValidator</value>
</validated-by>
</constraint-definition>
See: Configuring via XML
The upcoming 5.2 release provides more ways such as using a service loader or implementing ConstraintDefinitionContributor
. See: Providing constraint definitions