-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Currently the validation pipeline in ASP.NET Core returns a HTTP Status code of 400
which means BadRequest
.
httpstatuses.com describes a status code of 400
as the following:
400 BAD REQUEST
The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
I believe the validation pipeline should return a 422
which is Unprocessable Entity
.
422 UNPROCESSABLE ENTITY
The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.
It should be assumed that if the ASP.NET Core pipeline has a chance to get through model binding and run validators, it means the syntax of the request was valid (especially around an API call).
This change would keep the HTTP status code in the family of 4xx
error codes.