Support way to extract ConstraintViolation
from HandlerMethodValidationException
#33025
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Affects: 6.1.x or higher
I have been migrating from AOP method validation via
@Validated
to Spring MVC built-in method validation, added in 6.1, for queryString variable with@Constraint
annotations on my controller. I have noticed that there is no simple way to extract the cause of newly thrownHandlerMethodValidationException
when replacing old handler method forConstraintViolationException
.Despite the fact that document describes
HandlerMethodValidationException
is "very similar" to the good oldMethodArgumentNotValidException,
it lacks of the way to extract the source,ConstraintViolation
while withMethodArgumentNotValidException
from validating@RequestBody
, you could get simply get it throughObjectError
orFieldError
in the exception.HandlerMethodValidationException
from validating queryString only containsDefaultMessageSourceResolvable
. I think if it contains some kind of "ViolationParameterError
" or something just likeMethodArgumentNotValidException
, it would be great to have unifying handler method for any validation exceptions from controller layer.The text was updated successfully, but these errors were encountered: