Class ResourceBundleConstraintDescriptionResolver
java.lang.Object
org.springframework.restdocs.constraints.ResourceBundleConstraintDescriptionResolver
- All Implemented Interfaces:
ConstraintDescriptionResolver
public class ResourceBundleConstraintDescriptionResolver
extends Object
implements ConstraintDescriptionResolver
A
ConstraintDescriptionResolver
that resolves constraint descriptions from a
ResourceBundle
. The resource bundle's keys are the name of the constraint with
.description
appended. For example, the key for the constraint named
jakarta.validation.constraints.NotNull
is
jakarta.validation.constraints.NotNull.description
.
Default descriptions are provided for Bean Validation 2.0's constraints:
AssertFalse
AssertTrue
DecimalMax
DecimalMin
Digits
Email
Future
FutureOrPresent
Max
Min
Negative
NegativeOrZero
NotBlank
NotEmpty
NotNull
Null
Past
PastOrPresent
Pattern
Positive
PositiveOrZero
Size
Default descriptions are also provided for Hibernate Validator's constraints:
CodePointLength
CreditCardNumber
Currency
EAN
Email
Length
LuhnCheck
Mod10Check
Mod11Check
NotBlank
NotEmpty
Range
URL
- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorDescriptionCreates a newResourceBundleConstraintDescriptionResolver
that will resolve descriptions by looking them up in a resource bundle with the base nameorg.springframework.restdocs.constraints.ConstraintDescriptions
in the default locale loaded using the thread context class loader.ResourceBundleConstraintDescriptionResolver
(ResourceBundle resourceBundle) Creates a newResourceBundleConstraintDescriptionResolver
that will resolve descriptions by looking them up in the givenresourceBundle
. -
Method Summary
Modifier and TypeMethodDescriptionresolveDescription
(Constraint constraint) Resolves the description for the givenconstraint
.
-
Constructor Details
-
ResourceBundleConstraintDescriptionResolver
public ResourceBundleConstraintDescriptionResolver()Creates a newResourceBundleConstraintDescriptionResolver
that will resolve descriptions by looking them up in a resource bundle with the base nameorg.springframework.restdocs.constraints.ConstraintDescriptions
in the default locale loaded using the thread context class loader. -
ResourceBundleConstraintDescriptionResolver
Creates a newResourceBundleConstraintDescriptionResolver
that will resolve descriptions by looking them up in the givenresourceBundle
.- Parameters:
resourceBundle
- the resource bundle
-
-
Method Details
-
resolveDescription
Description copied from interface:ConstraintDescriptionResolver
Resolves the description for the givenconstraint
.- Specified by:
resolveDescription
in interfaceConstraintDescriptionResolver
- Parameters:
constraint
- the constraint- Returns:
- the description
-