Ticket #7064: 7064.diff

File 7064.diff, 968 bytes (added by Marc Fargas, 16 years ago)

added test.

  • django/core/validators.py

    diff --git a/django/core/validators.py b/django/core/validators.py
    index e728dbc..f6204c1 100644
    a b class IsValidDecimal(object):  
    437437            raise ValidationError, _("Please enter a valid decimal number.")
    438438
    439439        pieces = str(val).lstrip("-").split('.')
     440        if pieces[0] == '0' and ((len(pieces) == 2) and len(pieces[1])):
     441            pieces[0] = ''
    440442        decimals = (len(pieces) == 2) and len(pieces[1]) or 0
    441443        digits = len(pieces[0])
    442444
  • tests/modeltests/validation/models.py

    diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
    index 63f9f7a..40de933 100644
    a b u'john@example.com'  
    154154>>> errors['birthdate']
    155155[u'This field is required.']
    156156
     157>>> from django.core.validators import IsValidDecimal
     158>>> valdec = IsValidDecimal(2, 2)
     159>>> valdec('.00', [])
     160
    157161"""}
Back to Top