#5232 closed (fixed)
DecimalField max_digits counts negative sign as a digit.
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Validators | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In [5680], the validation of decimal values for DecimalField was changed to fix #4807, which also introduced a bug in validating negative decimals, in that it counts the - sign as one of the digits:
>>> import django.core.validators >>> v = django.core.validators.IsValidDecimal(max_digits=5, decimal_places=2) >>> v('999.99', {}) >>> v('-99.99', {}) >>> v('-999.99', {}) # This should succeed Traceback (most recent call last): ... django.core.validators.ValidationError: [u'Please enter a valid decimal number with at most 5 total digits.']
This error affects django.core.validators.IsValidDecimal and django.newforms.fields.DecimalField.
The attached patch fixes the problem and adds a regression test for it
Attachments (1)
Change History (4)
by , 17 years ago
Attachment: | decimalfield.diff added |
---|
comment:1 by , 17 years ago
Has patch: | set |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 17 years ago
Summary: | DecimalField max_digits counts -ve sign as a digit. → DecimalField max_digits counts negative sign as a digit. |
---|
Note:
See TracTickets
for help on using tickets.
Patch