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 TypeMethodDescriptionvoid
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> modelAttribitePredicate, Predicate<org.springframework.core.MethodParameter> requestParamPredicate) Static factory method to create aHandlerMethodValidator
when Bean Validation is enabled for use viaConfigurableWebBindingInitializer
, 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)
-
Method Details
-
determineValidationGroups
- Specified by:
determineValidationGroups
in interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 interfaceorg.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 aHandlerMethodValidator
when Bean Validation is enabled for use viaConfigurableWebBindingInitializer
, for example in Spring MVC or WebFlux config.
-