-
Notifications
You must be signed in to change notification settings - Fork 38.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Built-in support for standard bean validation on controller method arguments #24913
Comments
Hi, Use annotation |
Team decision: we are going to provide first-class support for bean validation that's built at the web framework level (Spring MVC and WebFlux), without requiring a separate post-processor and an AOP proxy. |
I'm closing this in favor of #29825 that summarizes issues with validation across multiple issues, and also highlights some of the design questions. Please take a look and provide further feedback if necessary under the new issue. |
Related to #11041.
I'm trying to validate
@PathVariable
and@RequestBody
in one method.MethodValidationPostProcessor
is registered. Simplified Controller looks like this:I noticed that request body validation is triggered twice - it wouldn't be an issue if it weren't custom
ConstraintValidator
with injected bean:For first validation run the bean is injected properly, and for second run it's null so it results in NPE. Workaround is to either not use method parameter validation at all, or to annotate
@RequestBody
with@Validated
so not mix@Validated
and@Valid
. I would actually prefer to have@PathVariable
bean validation support in Spring like in #11041.The text was updated successfully, but these errors were encountered: