Ticket #2760: validators.2.diff

File validators.2.diff, 1.1 KB (added by Eddy Mulyono <eddymulyono@…>, 18 years ago)

This works for me.

  • validators.py

     
    377377        if len(data) > max_allowed_length:
    378378            raise ValidationError, ngettext("Please enter a valid decimal number with at most %s total digit.",
    379379                "Please enter a valid decimal number with at most %s total digits.", self.max_digits) % self.max_digits
    380         if (not '.' in data and len(data) > (max_allowed_length - self.decimal_places)) or ('.' in data and len(data) > (self.max_digits - (self.decimal_places - len(data.split('.')[1])) + 1)):
     380        if (not '.' in data and len(data) > (self.max_digits - self.decimal_places) + 1) or ('.' in data and len(data) > max_allowed_length - (self.decimal_places - len(data.split('.')[1]))):
    381381            raise ValidationError, ngettext( "Please enter a valid decimal number with a whole part of at most %s digit.",
    382382                "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)
    383383        if '.' in data and len(data.split('.')[1]) > self.decimal_places:
Back to Top