- Notifications
You must be signed in to change notification settings - Fork 38.9k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug
Milestone
Description
Version
- spring framework: 6.1.1 (spring boot 3.2.0)
Situation
I tested below spring MVC rest controller and model. (use kotlin)
@RestController @RequestMapping(value = ["/api"]) class FooController { @PostExchange("/foo") fun createFoo( @RequestBody @Valid myData: MyData, @Min(1) @RequestParam("hint") hint: Int ): Map<String, Any?> { return mapOf("myData" to myData) } } data class MyData( val name: String, @get:Min(1) val age: Int )And call api and debug.
> curl -X POST \ -H 'Content-Type: application/json' \ 'http://localhost:8080/api/foo?hint=2' \ -d '{"name": "foo-1", "age": 3}'Then, the validation of age field occurs twice.
Is this behavior valid?
Related code
In invokeForRequest method, executed getMethodArgumentValues method first and then methodValidator.applyArgumentValidation method.
If requestBody is validate object and built-in method validation is activated, then request body object is validated twice.
Line 171 in 61be452
| Object[] args = getMethodArgumentValues(request, mavContainer, providedArgs); |
Line 178 in 61be452
| this.methodValidator.applyArgumentValidation( |
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: bugA general bugA general bug