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 TypeMethodDescriptionvoidapplyArgumentValidation(Object target, Method method, org.springframework.core.MethodParameter[] parameters, Object[] arguments, Class<?>[] groups) voidapplyReturnValueValidation(Object target, Method method, org.springframework.core.MethodParameter returnType, Object returnValue, Class<?>[] groups) Class<?>[]determineValidationGroups(Object target, Method method) static org.springframework.validation.method.MethodValidatorfrom(WebBindingInitializer initializer, org.springframework.core.ParameterNameDiscoverer paramNameDiscoverer, Predicate<org.springframework.core.MethodParameter> modelAttributePredicate, Predicate<org.springframework.core.MethodParameter> requestParamPredicate) Static factory method to create aHandlerMethodValidatorwhen Bean Validation is enabled for use viaConfigurableWebBindingInitializer, for example in Spring MVC or WebFlux config.org.springframework.validation.method.MethodValidationResultvalidateArguments(Object target, Method method, org.springframework.core.MethodParameter[] parameters, Object[] arguments, Class<?>[] groups) org.springframework.validation.method.MethodValidationResultvalidateReturnValue(Object target, Method method, org.springframework.core.MethodParameter returnType, Object returnValue, Class<?>[] groups)
-
Method Details
-
determineValidationGroups
- Specified by:
determineValidationGroupsin 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:
applyArgumentValidationin 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:
validateArgumentsin 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:
applyReturnValueValidationin 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:
validateReturnValuein 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> modelAttributePredicate, Predicate<org.springframework.core.MethodParameter> requestParamPredicate) Static factory method to create aHandlerMethodValidatorwhen Bean Validation is enabled for use viaConfigurableWebBindingInitializer, for example in Spring MVC or WebFlux config.
-