Added check for error message

This commit is contained in:
ben 2022-05-17 22:02:54 +01:00
parent bb5b04b307
commit ca8f649fd6
2 changed files with 6 additions and 1 deletions

View file

@ -12,7 +12,7 @@ class CreateWithdrawData(BaseModel):
title: str = Query(...) title: str = Query(...)
min_withdrawable: int = Query(..., ge=1) min_withdrawable: int = Query(..., ge=1)
max_withdrawable: int = Query(..., ge=1) max_withdrawable: int = Query(..., ge=1)
uses: int = Query(..., ge=1, le=250) uses: int = Query(..., ge=1)
wait_time: int = Query(..., ge=1) wait_time: int = Query(..., ge=1)
is_unique: bool is_unique: bool

View file

@ -71,6 +71,11 @@ async def api_link_create_or_update(
link_id: str = None, link_id: str = None,
wallet: WalletTypeInfo = Depends(require_admin_key), wallet: WalletTypeInfo = Depends(require_admin_key),
): ):
if data.uses > 250:
raise HTTPException(
detail="250 uses max.", status_code=HTTPStatus.BAD_REQUEST
)
if data.min_withdrawable < 1: if data.min_withdrawable < 1:
raise HTTPException( raise HTTPException(
detail="Min must be more than 1.", status_code=HTTPStatus.BAD_REQUEST detail="Min must be more than 1.", status_code=HTTPStatus.BAD_REQUEST