Package org.springframework.web.method.annotation

# 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 Summary

Modifier and Type
Method
Description
`void`
`applyArgumentValidation(Object target, Method method, org.springframework.core.MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)`
`void`
`applyReturnValueValidation(Object target, Method method, org.springframework.core.MethodParameter returnType, Object returnValue, Class<?>[] groups)`
`Class<?>[]`
`determineValidationGroups(Object target, Method method)`
`static org.springframework.validation.method.MethodValidator`
`from(WebBindingInitializer initializer, org.springframework.core.ParameterNameDiscoverer paramNameDiscoverer, Predicate<org.springframework.core.MethodParameter> modelAttributePredicate, 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.
`org.springframework.validation.method.MethodValidationResult`
`validateArguments(Object target, Method method, org.springframework.core.MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)`
`org.springframework.validation.method.MethodValidationResult`
`validateReturnValue(Object target, Method method, org.springframework.core.MethodParameter returnType, Object returnValue, Class<?>[] groups)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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> modelAttributePredicate, 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.