Skip to content

Custom validation message / http response for MapRequestPayload #58295

Answered by stof
herndlm asked this question in Q&A
Discussion options

You must be logged in to vote

You could use a listener for the ExceptionEvent.

Failures in the resolution of arguments with MapRequestPayload will report an HttpException with a status code 422 (unless your MapRequestPayload explicit changes the status code used for validation failure) with a ValidationFailedException (which allows accessing the violation list) as its previous exception. This can allow you to create a custom response for those error.

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@herndlm
Comment options

Answer selected by herndlm
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants