Class ValidatorConstraintResolver
java.lang.Object
org.springframework.restdocs.constraints.ValidatorConstraintResolver
- All Implemented Interfaces:
ConstraintResolver
A
ConstraintResolver
that uses a Bean Validation Validator
to resolve
constraints. The name of the constraint is the fully-qualified class name of the
constraint annotation. For example, a NotNull
constraint will be named
jakarta.validation.constraints.NotNull
.- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorDescriptionCreates a newValidatorConstraintResolver
that will use aValidator
in its default configuration to resolve constraints.ValidatorConstraintResolver
(jakarta.validation.Validator validator) Creates a newValidatorConstraintResolver
that will use the givenValidator
to resolve constraints. -
Method Summary
Modifier and TypeMethodDescriptionresolveForProperty
(String property, Class<?> clazz) Resolves and returns the constraints for the givenproperty
on the givenclazz
.
-
Constructor Details
-
ValidatorConstraintResolver
public ValidatorConstraintResolver()Creates a newValidatorConstraintResolver
that will use aValidator
in its default configuration to resolve constraints.- See Also:
-
Validation.buildDefaultValidatorFactory()
ValidatorFactory.getValidator()
-
ValidatorConstraintResolver
public ValidatorConstraintResolver(jakarta.validation.Validator validator) Creates a newValidatorConstraintResolver
that will use the givenValidator
to resolve constraints.- Parameters:
validator
- the validator
-
-
Method Details
-
resolveForProperty
Description copied from interface:ConstraintResolver
Resolves and returns the constraints for the givenproperty
on the givenclazz
. If there are no constraints, an empty list is returned.- Specified by:
resolveForProperty
in interfaceConstraintResolver
- Parameters:
property
- the propertyclazz
- the class- Returns:
- the list of constraints, never
null
-