❔ When using AbstractValidator, is there any way that i can override the http status code?
Im trying to return a 422 HTTP Status code when the error occurs, but by default it returns a 400 Bad Request, is there any way to override this. I attached a snippet of the validator code
3 Replies
No, because its not up to the validator
The 400 bad request is returned by the http pipeline if a exception is thrown at a certain time, You can add your own middleware to return 422
here is a medium article that does it for a whole bunch of exceptions. figure out waht exception is thrown by Fluent and catch that yourself in a middleware like this
Medium
Exception Middleware in .NET Core Applications
Understanding and Implementing Exception Middleware in .NET Core Applications
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.