Need to retrieve original validated object from MethodArgumentNotValidException

Viewed 38

I have a List with JSR Validations like @Max, @Min, and a Dto with inner list like:

"data": [
  {
   "id": 1,
   "age": 110, //@Max(100)
  },
  {
   "id": 2,
   "age": 200, //@Max(100)
}]

I want to handle JSR with @ControllerAdvice and overriding handleMethodArgumentNotValid method. If I try to inspect BindingResult instance I can get all errors but they are instances from SpringValidatorAdapter.ViolationFieldError

Inside this class, ViolationFieldError, there is a property named violation and inside this a leafBeanInstance with the original object from the list.

I cannot use this because, ViolationFieldError is a private class

How can I deal with this? Suggestions?

Thanks

0 Answers
Related