async def METHOD_NAME(
    request: Request,
    error: RequestValidationError,
) -> JSONResponse:
    """Map a validation error from the framework to an API response."""
    validation_errors = error.errors()
    if _route_is_legacy(request):
        message = "; ".join(
            f"{'.'.join([str(v) for v in val_error['loc']])}: {val_error['msg']}"
            for val_error in validation_errors
        )
        response: BaseErrorBody = LegacyErrorResponse(
            message=message, errorCode=ErrorCodes.GENERAL_ERROR.value.code
        )
    else:
        response = MultiErrorResponse(
            errors=[
                InvalidRequest(
                    detail=val_error["msg"],
                    source=_format_validation_source(val_error["loc"]),
                )
                for val_error in validation_errors
            ]
        )
    return await handle_api_error(
        request,
        response.as_error(status.HTTP_422_UNPROCESSABLE_ENTITY),
    )