Django

Code

Changeset 3142

Show
Ignore:
Timestamp:
06/18/06 20:09:00 (2 years ago)
Author:
mtredinnick
Message:

Fixed #1088 - Correctly detect when a float with too many digits before the
decimal point is passed in.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/validators.py

    r3113 r3142  
    356356            raise ValidationError, ngettext("Please enter a valid decimal number with at most %s total digit.", 
    357357                "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) 
    358361        if '.' in data and len(data.split('.')[1]) > self.decimal_places: 
    359362            raise ValidationError, ngettext("Please enter a valid decimal number with at most %s decimal place.",