|
|
|
|
@ -152,17 +152,26 @@ class RequestValidationMiddleware(BaseHTTPMiddleware):
|
|
|
|
|
for key, value in params:
|
|
|
|
|
if value:
|
|
|
|
|
inspect_value(value, f"query param '{key}'")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Pagination constraint: multiples of 5, max 50
|
|
|
|
|
if key in pagination_size_keys and value:
|
|
|
|
|
try:
|
|
|
|
|
size_val = int(value)
|
|
|
|
|
if size_val > 50:
|
|
|
|
|
raise HTTPException(status_code=400, detail=f"Pagination size '{key}' cannot exceed 50")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=400,
|
|
|
|
|
detail=f"Pagination size '{key}' cannot exceed 50",
|
|
|
|
|
)
|
|
|
|
|
if size_val % 5 != 0:
|
|
|
|
|
raise HTTPException(status_code=400, detail=f"Pagination size '{key}' must be a multiple of 5")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=400,
|
|
|
|
|
detail=f"Pagination size '{key}' must be a multiple of 5",
|
|
|
|
|
)
|
|
|
|
|
except ValueError:
|
|
|
|
|
raise HTTPException(status_code=400, detail=f"Pagination size '{key}' must be an integer")
|
|
|
|
|
raise HTTPException(
|
|
|
|
|
status_code=400,
|
|
|
|
|
detail=f"Pagination size '{key}' must be an integer",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# -------------------------
|
|
|
|
|
# 4. Content-Type sanity
|
|
|
|
|
|