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 @Nullable [] parameters, @Nullable Object[] arguments, Class<?>[] groups) voidapplyReturnValueValidation(Object target, Method method, @Nullable org.springframework.core.MethodParameter returnType, @Nullable Object returnValue, Class<?>[] groups) Class<?>[]determineValidationGroups(Object target, Method method) static @Nullable org.springframework.validation.method.MethodValidatorfrom(@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.org.springframework.validation.method.MethodValidationResultvalidateArguments(Object target, Method method, org.springframework.core.MethodParameter @Nullable [] parameters, @Nullable Object[] arguments, Class<?>[] groups) org.springframework.validation.method.MethodValidationResultvalidateReturnValue(Object target, Method method, @Nullable org.springframework.core.MethodParameter returnType, @Nullable Object returnValue, Class<?>[] groups)
-
Method Details
-
determineValidationGroups
-
applyArgumentValidation
-
validateArguments
public org.springframework.validation.method.MethodValidationResult validateArguments(Object target, Method method, org.springframework.core.MethodParameter @Nullable [] parameters, @Nullable Object[] arguments, Class<?>[] groups) - Specified by:
validateArgumentsin interfaceorg.springframework.validation.method.MethodValidator
-
applyReturnValueValidation
-
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
public static @Nullable 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.
-