A @Constraint annotation is normally mapped to ConstraintValidator(s) using the @Constraint#validatedBy annotation parameter.
This however has the limitation that the @Constraint annotation has to know about the ConstraintValidator(s) during compilation, which may not always be feasible (for example, if the annotation is used at the DTO layer, but a ConstraintValidator depends on the service layer, and the DTO layer is in a separate JAR file).
Most examples will simply create a new Validator bean, which will override the one created by Spring Boot.
The ValidationConfigurerAdapter
abstract class provided can be extended as a @Configuration to have the same behavior as Spring Boot's ValidationAutoConfiguration, but allows the mapping of @Constraint annotations to ConstraintValidators to be defined by overriding the mapConstraints(ConstraintMapping)
method. See https://docs.jboss.org/hibernate/validator/6.0/reference/en-US/html_single/#section-programmatic-constraint-definition for instructions on how to configure the mappings programmatically.