Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #1088 - Correctly detect when a float with too many digits befo…

…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...
commit c0ea3284d705a5d66c8aff372a5e33b15dce56e7 1 parent c256dcd
Malcolm Tredinnick authored June 19, 2006

Showing 1 changed file with 3 additions and 0 deletions. Show diff stats Hide diff stats

  1. 3  django/core/validators.py
3  django/core/validators.py
@@ -355,6 +355,9 @@ def __call__(self, field_data, all_data):
355 355
         if len(data) > (self.max_digits + 1):
356 356
             raise ValidationError, ngettext("Please enter a valid decimal number with at most %s total digit.",
357 357
                 "Please enter a valid decimal number with at most %s total digits.", self.max_digits) % self.max_digits
  358
+        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)):
  359
+            raise ValidationError, ngettext( "Please enter a valid decimal number with a whole part of at most %s digit.",
  360
+                "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)
358 361
         if '.' in data and len(data.split('.')[1]) > self.decimal_places:
359 362
             raise ValidationError, ngettext("Please enter a valid decimal number with at most %s decimal place.",
360 363
                 "Please enter a valid decimal number with at most %s decimal places.", self.decimal_places) % self.decimal_places

0 notes on commit c0ea328

Please sign in to comment.
Something went wrong with that request. Please try again.