mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-27 02:58:40 +02:00
initial commit
This commit is contained in:
18
app/apps/transactions/validators.py
Normal file
18
app/apps/transactions/validators.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
def validate_decimal_places(value):
|
||||
if abs(value.as_tuple().exponent) > 18:
|
||||
raise ValidationError(
|
||||
_("%(value)s has too many decimal places. Maximum is 18."),
|
||||
params={"value": value},
|
||||
)
|
||||
|
||||
|
||||
def validate_non_negative(value):
|
||||
if value < 0:
|
||||
raise ValidationError(
|
||||
_("%(value)s is not a non-negative number"),
|
||||
params={"value": value},
|
||||
)
|
||||
Reference in New Issue
Block a user