debugging validate dollars

This commit is contained in:
forest 2021-12-14 01:35:17 -06:00
parent db4797c044
commit 2b14627319
1 changed files with 6 additions and 7 deletions

View File

@ -39,12 +39,15 @@ def validate_dollars(min: float, max: float):
minAsDecimal = decimal.Decimal(min)
maxAsDecimal = decimal.Decimal(max)
current_app.logger.info(f"{str(dollars)} {str(minAsDecimal)} {str(dollars < minAsDecimal)}")
if dollars and dollars < minAsDecimal:
errors.append(f"dollars must be {str(minAsDecimal)} or more")
elif dollars and dollars >= maxAsDecimal:
errors.append(f"dollars must be less than {str(maxAsDecimal)}")
return [errors, dollars]
return [dollars, errors]
@bp.route("/btcpay", methods=("GET", "POST"))
@account_required
@ -56,9 +59,7 @@ def btcpay_payment():
return redirect(url_for("console.account_balance"))
if request.method == "POST":
result = validate_dollars(0.01, 1000)
errors = result[0]
dollars = result[1]
dollars, errors = validate_dollars(0.01, 1000)
if len(errors) == 0:
try:
@ -150,9 +151,7 @@ def stripe_payment():
errors = list()
if request.method == "POST":
result = validate_dollars(0.5, 1000000)
errors = result[0]
dollars = result[1]
dollars, errors = validate_dollars(0.5, 1000000)
if len(errors) == 0: