Top Description Methods
org.springframework.validation.method

public Interface MethodValidator

Known Direct Implementers
org.springframework.validation.beanvalidation.MethodValidationAdapter
Imports
java.lang.reflect.Method, org.springframework.core.MethodParameter, org.springframework.lang.Nullable

Contract to apply method validation and handle the results. Exposes methods that return MethodValidationResult, and methods that handle the results, by default raising MethodValidationException.
Author
Rossen Stoyanchev
Since
6.1

Method Summary

Modifier and TypeMethod and Description
public default void
applyArgumentValidation(Object target, Method method, MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)

Delegate to validateArguments and handle the validation result, by default raising MethodValidationException in case of errors.

public default void
applyReturnValueValidation(Object target, Method method, MethodParameter returnType, Object returnValue, Class<?>[] groups)

Delegate to validateReturnValue and handle the validation result, by default raising MethodValidationException in case of errors.

public Class<?>[]

Returns:

the applicable validation groups as a Class array
determineValidationGroups
(Object
the target Object
target
,
Method
the target method
method
)

Determine the applicable validation groups.

public MethodValidationResult

Returns:

the result of validation
validateArguments
(Object
the target Object
target
,
Method
the target method
method
,
MethodParameter[]
the parameters, if already created and available
parameters
,
Object[]
the candidate argument values to validate
arguments
,
Class<?>[]
validation groups from determineValidationGroups
groups
)

Validate the given method arguments and return validation results.

public MethodValidationResult

Returns:

the result of validation
validateReturnValue
(Object
the target Object
target
,
Method
the target method
method
,
MethodParameter
the return parameter, if already created and available
returnType
,
Object
the return value to validate
returnValue
,
Class<?>[]
validation groups from determineValidationGroups
groups
)

Validate the given return value and return validation results.

Method Detail

applyArgumentValidationback to summary
public default void applyArgumentValidation(Object target, Method method, MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)

Delegate to validateArguments and handle the validation result, by default raising MethodValidationException in case of errors. Implementations may provide alternative handling, e.g. injecting org.springframework.validation.Errors into the method.

Exceptions
MethodValidationException:
in case of unhandled errors.
applyReturnValueValidationback to summary
public default void applyReturnValueValidation(Object target, Method method, MethodParameter returnType, Object returnValue, Class<?>[] groups)

Delegate to validateReturnValue and handle the validation result, by default raising MethodValidationException in case of errors. Implementations may provide alternative handling.

Exceptions
MethodValidationException:
in case of unhandled errors.
determineValidationGroupsback to summary
public Class<?>[] determineValidationGroups(Object target, Method method)

Determine the applicable validation groups. By default, obtained from an @Validated annotation on the method, or on the class level.

Parameters
target:Object

the target Object

method:Method

the target method

Returns:Class<?>[]

the applicable validation groups as a Class array

validateArgumentsback to summary
public MethodValidationResult validateArguments(Object target, Method method, MethodParameter[] parameters, Object[] arguments, Class<?>[] groups)

Validate the given method arguments and return validation results.

Parameters
target:Object

the target Object

method:Method

the target method

parameters:MethodParameter[]

the parameters, if already created and available

arguments:Object[]

the candidate argument values to validate

groups:Class<?>[]

validation groups from determineValidationGroups

Returns:MethodValidationResult

the result of validation

validateReturnValueback to summary
public MethodValidationResult validateReturnValue(Object target, Method method, MethodParameter returnType, Object returnValue, Class<?>[] groups)

Validate the given return value and return validation results.

Parameters
target:Object

the target Object

method:Method

the target method

returnType:MethodParameter

the return parameter, if already created and available

returnValue:Object

the return value to validate

groups:Class<?>[]

validation groups from determineValidationGroups

Returns:MethodValidationResult

the result of validation