summaryrefslogtreecommitdiff
path: root/django/core/validators.py
diff options
context:
space:
mode:
authorKamil Turek <kamil.turek@hotmail.com>2022-09-16 21:43:12 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-09-17 10:02:55 +0200
commitae509f8f0804dea0eea89e27329014616c9d4cc0 (patch)
tree2b16a90aae0b0e3d094b4d3b1481647770c2401b /django/core/validators.py
parentc11336cd990e155371a5185cf3bd6942cad8d9da (diff)
Fixed #34014 -- Fixed DecimalValidator validating 0 in positive exponent scientific notation.
Thanks Shiplu Mokaddim for the report.
Diffstat (limited to 'django/core/validators.py')
-rw-r--r--django/core/validators.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/django/core/validators.py b/django/core/validators.py
index 473203a67e..c73490588d 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -486,8 +486,10 @@ class DecimalValidator:
self.messages["invalid"], code="invalid", params={"value": value}
)
if exponent >= 0:
- # A positive exponent adds that many trailing zeros.
- digits = len(digit_tuple) + exponent
+ digits = len(digit_tuple)
+ if digit_tuple != (0,):
+ # A positive exponent adds that many trailing zeros.
+ digits += exponent
decimals = 0
else:
# If the absolute value of the negative exponent is larger than the