I noticed that all built-in constraints have an empty value for the validatedBy
parameter in @Constraint
. i.e. @Constraint(validatedBy = {})
Those built-in are treated in special implementation-specific way and their validators are configured programmatically.
For Hibernate Validator it's done in ConstraintHelper.java. I think you can't achieve the same for your custom constraints.
Maybe have a look at this answer:
How to avoid cross dependency between layers because of @Constraint validatedBy?
And those two links:
Adding constraints programmatically: http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html/validator-specifics.html#section-programmatic-api
Adding constraints per xml: http://docs.jboss.org/hibernate/validator/4.1/reference/en-US/html/validator-xmlconfiguration.html