[Django] #28562: DecimalValidator raises ValidationError for decimals in scientific notation

32 views
Skip to first unread message

Django

unread,
Sep 2, 2017, 3:23:22 PM9/2/17
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
-------------------------------------------+------------------------
Reporter: Maksim Iakovlev | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.11
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
{{{
>>> validator = DecimalValidator(20, 2)
>>> value = Decimal('7.42403889818E+17')
>>> try:
... validator(value)
... except Exception as e:
... print(e)
...
[u'Ensure that there are no more than 2 decimal places.']
>>> value = Decimal(742403889818000000)
>>> try:
... validator(value)
... except Exception as e:
... print(e)
...
>>>
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28562>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 3, 2017, 12:22:45 AM9/3/17
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
---------------------------------+------------------------------------

Reporter: Maksim Iakovlev | Owner: nobody
Type: Bug | Status: new
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by Josh Schneier):

* type: Uncategorized => Bug
* version: 1.11 => master
* component: Uncategorized => Core (Other)
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:1>

Django

unread,
Sep 3, 2017, 5:37:04 PM9/3/17
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
---------------------------------+-----------------------------------------
Reporter: Maksim Iakovlev | Owner: Josh Schneier
Type: Bug | Status: assigned

Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------------------------------
Changes (by Josh Schneier):

* owner: nobody => Josh Schneier
* status: new => assigned
* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/9015 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:2>

Django

unread,
Sep 9, 2017, 3:23:36 AM9/9/17
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
-------------------------------------+-------------------------------------

Reporter: Maksim Iakovlev | Owner: Josh
| Schneier
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Martin):

* cc: Tim Martin (added)
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:3>

Django

unread,
Sep 27, 2017, 9:42:21 AM9/27/17
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
-------------------------------------+-------------------------------------
Reporter: Maksim Iakovlev | Owner: Josh
| Schneier
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"e8c45963296eb8bf3938bf9ece30b585a8cbb097" e8c45963]:
{{{
#!CommitTicketReference repository=""
revision="e8c45963296eb8bf3938bf9ece30b585a8cbb097"
Fixed #28562 -- Fixed DecimalValidator handling of positive exponent
scientific notation.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:4>

Django

unread,
Sep 27, 2017, 9:48:20 AM9/27/17
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
-------------------------------------+-------------------------------------
Reporter: Maksim Iakovlev | Owner: Josh
| Schneier
Type: Bug | Status: closed
Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"7c6590af5f199c9ede970758877b5c1eb7e9b3a6" 7c6590af]:
{{{
#!CommitTicketReference repository=""
revision="7c6590af5f199c9ede970758877b5c1eb7e9b3a6"
[2.0.x] Fixed #28562 -- Fixed DecimalValidator handling of positive
exponent scientific notation.

Backport of e8c45963296eb8bf3938bf9ece30b585a8cbb097 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:5>

Django

unread,
Jan 26, 2018, 11:48:22 AM1/26/18
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
-------------------------------------+-------------------------------------
Reporter: Maksim Iakovlev | Owner: Josh
| Schneier
Type: Bug | Status: new

Component: Core (Other) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Josh Harwood):

* status: closed => new
* resolution: fixed =>


Comment:

Running version Django==2.0.1

With Example form

{{{
class UpdateBalanceForm(forms.Form):
id = forms.ModelChoiceField(ProductPortfolio.objects.all(),
required=True)
balance = forms.DecimalField(decimal_places=2, max_digits=16,
required=True)
}}}

Running the following you get

{{{
form = UpdateBalanceForm({'id':1,
'balance':Decimal('5.420575188741E-12')})
form.is_valid()
False
form.errors
{'id': ['Select a valid choice. That choice is not one of the available
choices.'], 'balance': ['Ensure that there are no more than 16 digits in
total.']}
}}}

This is surprising because the value has 13 digits minus the scientific
notation

--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:6>

Django

unread,
Jan 26, 2018, 11:55:57 AM1/26/18
to django-...@googlegroups.com
#28562: DecimalValidator raises ValidationError for decimals in scientific notation
-------------------------------------+-------------------------------------
Reporter: Maksim Iakovlev | Owner: Josh
| Schneier
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* status: new => closed
* resolution: => fixed


Comment:

Please open a new ticket as the fix for this ticket has been released.

--
Ticket URL: <https://code.djangoproject.com/ticket/28562#comment:7>

Reply all
Reply to author
Forward
0 new messages