Spring validation on multiple levels

75 views Asked by At

I have a controller where I have multiple levels of validation combined. The problem is that the validation on 'ToBeValidated' class are executed. But the '@SystemId' validation is skipped because of the '@Validated' annotation on the parameter 'ToBeValidated', when I remove this the opposite is true. Only the cross-parameter validation '@SystemId' is executed. How can I get spring to execute both together?

@Validated
public class Controller {

    @PutMapping(path = THEMA + "/{systemId}", consumes = APPLICATION_JSON_VALUE)
    @SystemId
    public ResponseEntity<Void> update(final @PathVariable("systemId") SystemId systemId,
                                       final @RequestBody @Validated(Update.class) ToBeValidated dto) {

       ....
    }

}

Tried using @Validated on different levels. I want to make both validation work.

0

There are 0 answers