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
ConstructorsConstructorDescriptionCreates a newValidatorConstraintResolverthat will use aValidatorin its default configuration to resolve constraints.ValidatorConstraintResolver(jakarta.validation.Validator validator) Creates a newValidatorConstraintResolverthat will use the givenValidatorto resolve constraints. -
Method Summary
Modifier and TypeMethodDescriptionresolveForProperty(String property, Class<?> clazz) Resolves and returns the constraints for the givenpropertyon the givenclazz.
-
Constructor Details
-
ValidatorConstraintResolver
public ValidatorConstraintResolver()Creates a newValidatorConstraintResolverthat will use aValidatorin its default configuration to resolve constraints.- See Also:
-
Validation.buildDefaultValidatorFactory()ValidatorFactory.getValidator()
-
ValidatorConstraintResolver
public ValidatorConstraintResolver(jakarta.validation.Validator validator) Creates a newValidatorConstraintResolverthat will use the givenValidatorto resolve constraints.- Parameters:
validator- the validator
-
-
Method Details
-
resolveForProperty
Description copied from interface:ConstraintResolverResolves and returns the constraints for the givenpropertyon the givenclazz. If there are no constraints, an empty list is returned.- Specified by:
resolveForPropertyin interfaceConstraintResolver- Parameters:
property- the propertyclazz- the class- Returns:
- the list of constraints, never
null
-