MethodInterceptor implementation that delegates to a
JSR-303 provider for performing method-level validation on annotated methods.
Applicable methods have jakarta. annotations on
their parameters and/or on their return value (in the latter case specified at
the method level, typically as inline annotation).
E.g.: public @NotNull Object myValidMethod(@NotNull String arg1, @Max(10) int arg2)
In case of validation errors, the interceptor can raise
ConstraintViolationException, or adapt the violations to
MethodValidationResult and raise MethodValidationException.
Validation groups can be specified through Spring's Validated annotation
at the type level of the containing target class, applying to all public service methods
of that class. By default, JSR-303 will validate against its default group only.
As of Spring 5.0, this functionality requires a Bean Validation 1.1+ provider.
MethodValidationPostProcessor, jakarta.validation.executable.ExecutableValidator
| Modifier and Type | Class and Description |
|---|---|
| private static class | MethodValidationInterceptor.
Helper class to decorate reactive arguments with async validation. |
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private static final boolean | |
| private final MethodValidationAdapter |
| Access | Constructor and Description |
|---|---|
| public | MethodValidationInterceptor()
Create a new MethodValidationInterceptor using a default JSR-303 validator underneath. |
| public | MethodValidationInterceptor(ValidatorFactory
the JSR-303 ValidatorFactory to use validatorFactory)Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory. |
| public | MethodValidationInterceptor(Validator
the JSR-303 Validator to use validator)Create a new MethodValidationInterceptor using the given JSR-303 Validator. |
| public | MethodValidationInterceptor(Supplier<Validator>
a Supplier for the Validator to use validator)Create a new MethodValidationInterceptor for the supplied (potentially lazily initialized) Validator. |
| public | MethodValidationInterceptor(Supplier<Validator>
a Supplier for the Validator to use validator, boolean whether to adapt adaptViolations)ConstraintViolations, and
if true, raise MethodValidationException, of if
false raise ConstraintViolationException insteadCreate a new MethodValidationInterceptor for the supplied (potentially lazily initialized) Validator. |
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected Class | Returns: the applicable validation groups as a Class arraythe current MethodInvocation invocation)Determine the validation groups to validate against for the given method invocation. |
| private static Object | |
| public Object | invoke(MethodInvocation
the method invocation joinpoint invocation)Implements org. Implement this method to perform extra treatments before and after the invocation. |
| private boolean |
| adaptViolations | back to summary |
|---|---|
| private final boolean adaptViolations | |
| REACTOR_PRESENT | back to summary |
|---|---|
| private static final boolean REACTOR_PRESENT | |
| validationAdapter | back to summary |
|---|---|
| private final MethodValidationAdapter validationAdapter | |
| MethodValidationInterceptor | back to summary |
|---|---|
| public MethodValidationInterceptor() Create a new MethodValidationInterceptor using a default JSR-303 validator underneath. | |
| MethodValidationInterceptor | back to summary |
|---|---|
| public MethodValidationInterceptor(ValidatorFactory validatorFactory) Create a new MethodValidationInterceptor using the given JSR-303 ValidatorFactory.
| |
| MethodValidationInterceptor | back to summary |
|---|---|
| public MethodValidationInterceptor(Validator validator) Create a new MethodValidationInterceptor using the given JSR-303 Validator.
| |
| MethodValidationInterceptor | back to summary |
|---|---|
| public MethodValidationInterceptor(Supplier<Validator> validator) Create a new MethodValidationInterceptor for the supplied (potentially lazily initialized) Validator. | |
| MethodValidationInterceptor | back to summary |
|---|---|
| public MethodValidationInterceptor(Supplier<Validator> validator, boolean adaptViolations) Create a new MethodValidationInterceptor for the supplied (potentially lazily initialized) Validator.
| |
| MethodValidationInterceptor | back to summary |
|---|---|
| private MethodValidationInterceptor(MethodValidationAdapter validationAdapter, boolean adaptViolations) | |
| determineValidationGroups | back to summary |
|---|---|
| protected Class Determine the validation groups to validate against for the given method invocation. Default are the validation groups as specified in the
| |
| getTarget | back to summary |
|---|---|
| private static Object getTarget(MethodInvocation invocation) | |
| invoke | back to summary |
|---|---|
| public Object invoke(MethodInvocation invocation) throws Throwable Implements org. Doc from org. Implement this method to perform extra treatments before and
after the invocation. Polite implementations would certainly
like to invoke
| |
| isFactoryBeanMetadataMethod | back to summary |
|---|---|
| private boolean isFactoryBeanMetadataMethod(Method method) | |
| Modifier and Type | Field and Description |
|---|---|
| private static final ReactiveAdapterRegistry |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static Class | |
| pack-priv static Object[] | insertAsyncValidation(Supplier<SpringValidatorAdapter> validatorAdapterSupplier, boolean adaptViolations, Object target, Method method, Object[] arguments)
|
| private static <T> void | validate(SpringValidatorAdapter validatorAdapter, boolean adaptViolations, Object target, Method method, MethodParameter parameter, Object argument, Class<?>[] groups)
|
| reactiveAdapterRegistry | back to summary |
|---|---|
| private static final ReactiveAdapterRegistry reactiveAdapterRegistry | |
| ReactorValidationHelper | back to summary |
|---|---|
| private ReactorValidationHelper() | |
| determineValidationGroups | back to summary |
|---|---|
private static Class
| |
| insertAsyncValidation | back to summary |
|---|---|
| pack-priv static Object[] insertAsyncValidation(Supplier<SpringValidatorAdapter> validatorAdapterSupplier, boolean adaptViolations, Object target, Method method, Object[] arguments) | |
| validate | back to summary |
|---|---|
private static <T> void validate(SpringValidatorAdapter validatorAdapter, boolean adaptViolations, Object target, Method method, MethodParameter parameter, Object argument, Class<?>[] groups)
| |