Ticket #1088: isValidFloat.diff

File isValidFloat.diff, 1.3 KB (added by Yango, 18 years ago)

A diff for the validator, don't pay attention to the pasted code as it's buggy

  • core/validators.py

     
    350350        if len(data) > (self.max_digits + 1):
    351351            raise ValidationError, ngettext( "Please enter a valid decimal number with at most %s total digit.",
    352352                "Please enter a valid decimal number with at most %s total digits.", self.max_digits) % self.max_digits
     353        if (not '.' in data and len(data) > (self.max_digits - self.decimal_places)) \
     354            or ('.' in data and len(data) > (self.max_digits - (self.decimal_places - len(data.split('.')[1])) + 1)):
     355            raise ValidationError, ngettext( "Please enter a valid decimal number with a whole part of at most %s digit.",
     356                "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)
    353357        if '.' in data and len(data.split('.')[1]) > self.decimal_places:
    354358            raise ValidationError, ngettext("Please enter a valid decimal number with at most %s decimal place.",
    355359                "Please enter a valid decimal number with at most %s decimal places.", self.decimal_places) % self.decimal_places
Back to Top