mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-01-11 20:00:26 +01:00
19 lines
527 B
Python
19 lines
527 B
Python
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},
|
|
)
|