Take sats as whole numbers in validate_sats
This commit is contained in:
1 parent
a016d31cc5
commit
d89b474eda
1 file changed
+4
-6
+4
-6
@@ -90,15 +90,13 @@ def validate_date(value):
|
||||
|
||||
|
||||
def validate_sats(value, optional=False):
|
||||
"""Return an amount of sats from a BTC amount written by the user."""
|
||||
"""Return a whole number of sats from what the owner typed."""
|
||||
if _blank(value):
|
||||
return (None, None) if optional else (None, "Antal må fyllast ut.")
|
||||
try:
|
||||
sats = rates.parse_btc_to_sats(value)
|
||||
except ValueError as error:
|
||||
if "8 decimals" in str(error):
|
||||
return None, "Antal kan ha høgst 8 desimalar."
|
||||
return None, "Antal må vere eit tal, t.d. 0,5."
|
||||
sats = rates.parse_sats(value)
|
||||
except ValueError:
|
||||
return None, "Antal må vere eit heiltal i sats."
|
||||
if sats <= 0:
|
||||
return None, "Antal må vere større enn null."
|
||||
return sats, None
|
||||
|
||||
Reference in new issue
Block a user