Skip to content

Built-in Web Support for Method Bean Validation #30645

Closed
@rstoyanchev

Description

@rstoyanchev

Currently bean validation is applied to @ModelAttribute and @RequestBody arguments if they are also annotated with jakarta.validation.Valid or Spring's @Validated with validation groups. You can put constraint annotations directly on other arguments, but that requires @Validated on the controller class with MethodValidationPostProcessor applying method validation via AOP.

This is not intuitive and creates challenges for handling validation errors, e.g. to handle either ConstraintViolationException or MethodArgumentNotValidException. Also need to introspect method parameters to know if the failure is for a request header, path variable, or other, see #26219. It can lead to double validation, see #24913. It does not support reactive types, see #20781.

We need built-in method validation in web handling for a more integrated experience, default web exception handling of constraint violations to RFC 7807 responses.

This is an umbrella issue for the improvement:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions