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:
AssertFalseAssertTrueDecimalMaxDecimalMinDigitsEmailFutureFutureOrPresentMaxMinNegativeNegativeOrZeroNotBlankNotEmptyNotNullNullPastPastOrPresentPatternPositivePositiveOrZeroSize
Default descriptions are also provided for Hibernate Validator's constraints:
CodePointLengthCreditCardNumberCurrencyEANEmailLengthLuhnCheckMod10CheckMod11CheckNotBlankNotEmptyRangeURL
- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newResourceBundleConstraintDescriptionResolverthat will resolve descriptions by looking them up in a resource bundle with the base nameorg.springframework.restdocs.constraints.ConstraintDescriptionsin the default locale loaded using the thread context class loader.ResourceBundleConstraintDescriptionResolver(ResourceBundle resourceBundle) Creates a newResourceBundleConstraintDescriptionResolverthat 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 newResourceBundleConstraintDescriptionResolverthat will resolve descriptions by looking them up in a resource bundle with the base nameorg.springframework.restdocs.constraints.ConstraintDescriptionsin the default locale loaded using the thread context class loader. -
ResourceBundleConstraintDescriptionResolver
Creates a newResourceBundleConstraintDescriptionResolverthat will resolve descriptions by looking them up in the givenresourceBundle.- Parameters:
resourceBundle- the resource bundle
-
-
Method Details
-
resolveDescription
Description copied from interface:ConstraintDescriptionResolverResolves the description for the givenconstraint.- Specified by:
resolveDescriptionin interfaceConstraintDescriptionResolver- Parameters:
constraint- the constraint- Returns:
- the description
-