MethodValidationPostProcessor class final

The bean that turns on method validation: it applies a MethodValidationInterceptor to every bean whose class is annotated @Validated().

Spring Boot's auto-configuration registers one as methodValidationPostProcessor, using the application's BeanValidator bean and leaving @ConfigurationProperties classes out. Declare your own only without Spring Boot, or to change the validator or the exclusions; Boot then backs off.

Despite its name it is an advisor, not a post-processor: proxies are generated at build time, so the context's auto proxy creator applies it like any advisor bean, also to beans that other advice already proxies.

// Method validation in a context without Spring Boot.
@Configuration()
class ValidationConfig {
  @Bean()
  MethodValidationPostProcessor methodValidationPostProcessor(
    BeanIntrospector introspector,
  ) => MethodValidationPostProcessor(
      BeanValidator(introspector: introspector));
}

Spring (Java):

@Bean
static MethodValidationPostProcessor methodValidationPostProcessor() {
  return new MethodValidationPostProcessor();
}
Implemented types

Constructors

MethodValidationPostProcessor([BeanValidator? validator, List<bool Function(List<Object> classAnnotations)> excludeFilters = const []])
An advisor that checks with validator (by default a new BeanValidator on BeanIntrospector.shared).

Properties

advice → MethodValidationInterceptor
The interceptor that runs around each advised call.
final
excludeFilters → List<bool Function(List<Object> classAnnotations)>
Tests on the annotations of a bean class; a bean is not validated when one returns true.
final
hashCode → int
The hash code for this object.
no setterinherited
order → int
Ordered.lowestPrecedence: validation runs innermost, after other advice such as caching, like Spring's validation advisor, which is added after the existing ones.
no setteroverride
pointcut → AnnotationPointcut
Matches the methods of beans whose class is annotated @Validated() and not excluded by excludeFilters.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

annotationTypes → const List<Type>
The annotation this advisor matches; the generator reads it to give a proxy class only to the beans that carry it.