MethodValidationInterceptor class final
The AOP advice that checks the arguments and the return value of a call against the method's constraints.
Before the call it checks the constraints on the parameters and the
insides of @Valid() parameters; after it, the constraints on the
method and, with @Valid() on the method, the inside of the result.
Violations throw a ConstraintViolationException; for a method that
returns a Future, the future completes with it. The groups come from
@Validated on the method, else on the class.
Applications do not create it: MethodValidationPostProcessor wraps one, and Spring Boot registers that. Build one yourself only to apply method validation with your own pointcut.
// Method validation for the beans of classes annotated @Validated.
final advisor = DefaultPointcutAdvisor(
const AnnotationMatchingPointcut<Validated>(onClass: true),
MethodValidationInterceptor(BeanValidator(introspector: introspector)),
);
Spring (Java):
new DefaultPointcutAdvisor(
new AnnotationMatchingPointcut(Validated.class, true),
new MethodValidationInterceptor(validator));
- Implemented types
Constructors
- MethodValidationInterceptor([BeanValidator? validator])
-
An interceptor that checks with
validator; by default a new BeanValidator onBeanIntrospector.shared.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- validator → BeanValidator
-
The validator that checks the arguments and results; its message
source and clock apply.
final
Methods
-
invoke(
MethodInvocation invocation) → Object? -
Runs around
invocationand returns the call's result.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
determineValidationGroups(
MethodSignature signature) → List< Type> -
The validation groups for a call of
signature: those of@Validatedon the method, else on a declaration it overrides (the nearest first), else on the bean class; empty when none names any.