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 Details

    • ResourceBundleConstraintDescriptionResolver

      public ResourceBundleConstraintDescriptionResolver()
      Creates a new ResourceBundleConstraintDescriptionResolver that will resolve descriptions by looking them up in a resource bundle with the base name org.springframework.restdocs.constraints.ConstraintDescriptions in the default locale loaded using the thread context class loader.
    • ResourceBundleConstraintDescriptionResolver

      public ResourceBundleConstraintDescriptionResolver(ResourceBundle resourceBundle)
      Creates a new ResourceBundleConstraintDescriptionResolver that will resolve descriptions by looking them up in the given resourceBundle.
      Parameters:
      resourceBundle - the resource bundle
  • Method Details