Decimal validation doesn't correctly handle max_digits == decimal_places
|Reported by:||cogg||Owned by:||kmtracey|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
If you have a decimal field defined in a model with max_digits and decimal_places set to the same value (for values 0 <= |n| < 1), you will get the following error message incorrectly when you enter any valid value:
- Please enter a valid decimal number with a whole part of at most 0 digits.
You will also get the following error message incorrectly if the number you enter has decimal_places number of digits:
- Please enter a valid decimal number with at most %s total digits.
This is because the leading 0 that str() produces is considered a digit in the validation code (e.g., .35 and 0.35 are treated as 3 digit numbers, with 0 as a digit in the "whole part").
Change History (7)
Changed 7 years ago by cogg
comment:1 Changed 7 years ago by telenieko
- Needs documentation unset
- Needs tests set
- Patch needs improvement set
- Triage Stage changed from Unreviewed to Accepted
Changed 7 years ago by telenieko
comment:3 Changed 7 years ago by kmtracey
- Owner changed from cogg to kmtracey
- Status changed from new to assigned
comment:4 Changed 7 years ago by kmtracey
- Resolution set to fixed
- Status changed from assigned to closed