Skip to content

Commit

Permalink
Fixed #1088 - Correctly detect when a float with too many digits befo…
Browse files Browse the repository at this point in the history
…re the

decimal point is passed in.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@3142 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Jun 19, 2006
1 parent c256dcd commit c0ea328
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions django/core/validators.py
Expand Up @@ -355,6 +355,9 @@ def __call__(self, field_data, all_data):
if len(data) > (self.max_digits + 1):
raise ValidationError, ngettext("Please enter a valid decimal number with at most %s total digit.",
"Please enter a valid decimal number with at most %s total digits.", self.max_digits) % self.max_digits
if (not '.' in data and len(data) > (self.max_digits - self.decimal_places)) or ('.' in data and len(data) > (self.max_digits - (self.decimal_places - len(data.split('.')[1])) + 1)):
raise ValidationError, ngettext( "Please enter a valid decimal number with a whole part of at most %s digit.",
"Please enter a valid decimal number with a whole part of at most %s digits.", str(self.max_digits-self.decimal_places)) % str(self.max_digits-self.decimal_places)
if '.' in data and len(data.split('.')[1]) > self.decimal_places:
raise ValidationError, ngettext("Please enter a valid decimal number with at most %s decimal place.",
"Please enter a valid decimal number with at most %s decimal places.", self.decimal_places) % self.decimal_places
Expand Down

0 comments on commit c0ea328

Please sign in to comment.