Skip to main content

request_validation_exception_handler

Handles FastAPI RequestValidationError by returning a JSONResponse with a 422 status code and a detailed list of validation errors.

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

Handles FastAPI RequestValidationError by returning a JSON response containing the validation error details.

Parameters​

NameTypeDescription
requestRequestThe incoming HTTP request object that triggered the validation error.
excRequestValidationErrorThe exception instance containing the specific validation errors encountered during request processing.

Returns​

TypeDescription
JSONResponseA JSON response with a 422 status code and a body containing the serialized validation error details.