Class HandlerMethodValidator

java.lang.Object
org.springframework.web.method.annotation.HandlerMethodValidator
All Implemented Interfaces:
org.springframework.validation.method.MethodValidator

public final class HandlerMethodValidator extends Object implements org.springframework.validation.method.MethodValidator
MethodValidator that uses Bean Validation to validate @RequestMapping method arguments.

Handles validation results by populating BindingResult method arguments with errors from beanResults. Also, helps to determine parameter names for @ModelAttribute and @RequestBody parameters.

Since:
6.1
Author:
Rossen Stoyanchev
  • Method Details

    • determineValidationGroups

      public Class<?>[] determineValidationGroups(Object target, Method method)
      Specified by:
      determineValidationGroups in interface org.springframework.validation.method.MethodValidator
    • applyArgumentValidation

      public void applyArgumentValidation(Object target, Method method, @Nullable org.springframework.core.MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)
      Specified by:
      applyArgumentValidation in interface org.springframework.validation.method.MethodValidator
    • validateArguments

      public org.springframework.validation.method.MethodValidationResult validateArguments(Object target, Method method, @Nullable org.springframework.core.MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)
      Specified by:
      validateArguments in interface org.springframework.validation.method.MethodValidator
    • applyReturnValueValidation

      public void applyReturnValueValidation(Object target, Method method, @Nullable org.springframework.core.MethodParameter returnType, @Nullable Object returnValue, Class<?>[] groups)
      Specified by:
      applyReturnValueValidation in interface org.springframework.validation.method.MethodValidator
    • validateReturnValue

      public org.springframework.validation.method.MethodValidationResult validateReturnValue(Object target, Method method, @Nullable org.springframework.core.MethodParameter returnType, @Nullable Object returnValue, Class<?>[] groups)
      Specified by:
      validateReturnValue in interface org.springframework.validation.method.MethodValidator
    • from

      @Nullable public static org.springframework.validation.method.MethodValidator from(@Nullable WebBindingInitializer initializer, @Nullable org.springframework.core.ParameterNameDiscoverer paramNameDiscoverer, Predicate<org.springframework.core.MethodParameter> modelAttribitePredicate, Predicate<org.springframework.core.MethodParameter> requestParamPredicate)
      Static factory method to create a HandlerMethodValidator when Bean Validation is enabled for use via ConfigurableWebBindingInitializer, for example in Spring MVC or WebFlux config.