Skip to main content

request_validation_exception_handler

Handles RequestValidationError exceptions by returning a JSON response with a 422 status code and details of the validation errors.

def request_validation_exception_handler(
request: Request,
exc: RequestValidationError
) - > JSONResponse

Handles request validation exceptions by returning a JSON response with a 422 status code and details about the validation errors. This function provides a standardized error response for invalid requests.

Parameters

NameTypeDescription
requestRequestThe incoming request object that caused the validation error.
excRequestValidationErrorThe exception object containing details about the request validation errors.

Returns

TypeDescription
JSONResponseA JSON response containing the validation error details and a 422 Unprocessable Entity status code.