#34014: DecimalValidator fails to validate 0 in scientific notation (0E+1 or
0E+2)
-------------------------------------+-------------------------------------
Reporter: Shiplu Mokaddim | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: 2.0
Severity: Normal | Resolution:
Keywords: DecimalValidator, | Triage Stage: Accepted
Decimal, DecimalField |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):
* cc: Josh Schneier (added)
* component: Forms => Core (Other)
* stage: Unreviewed => Accepted
Comment:
Thanks for the report. We should fix an edge case with `0`, maybe:
{{{#!diff
diff --git a/django/core/validators.py b/django/core/validators.py
index 473203a67e..446f97af10 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -487,7 +487,9 @@ class DecimalValidator:
)
if exponent >= 0:
# A positive exponent adds that many trailing zeros.
- digits = len(digit_tuple) + exponent
+ digits = len(digit_tuple)
+ if digit_tuple != (0,):
+ digits += exponent
decimals = 0
else:
# If the absolute value of the negative exponent is larger
than the
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/34014#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/01070183447d9f97-7b6cdbd8-d923-4faf-a17d-ee4b2feb4e0a-000000%40eu-central-1.amazonses.com.