0

I am creating a REST controller which shall take a list of Dtos. It all works but the validation is not working, therefore it fails during persistence only.

My code:

@Valid @RequestBody HashMap<String, MyDto> myDtoMap

And unfortunately the MyDto does not get validated.

I also tried this way:

@Valid @RequestBody HashMap<String, @Valid MyDto> myDtoMap
CodeWarrior
  • 354
  • 2
  • 3
  • 10

1 Answers1

4

Please try :

annotate your controller with :

@RestController
@Validated

Then you can validate you class with :

@RequestBody HashMap<String, @Valid MyDto> myDtoMap
Tung Phan
  • 66
  • 3