Django

Code

Show
Ignore:
Timestamp:
12/17/07 02:05:27 (1 year ago)
Author:
mtredinnick
Message:

Fixed #5871 -- Factored out the validation errors in localflavor form fields. Brings them into line with the standard newforms fields. Patch from Jan Rademaker.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/localflavor/pe/forms.py

    r6283 r6926  
    2020    A field that validates `Documento Nacional de IdentidadŽ (DNI) numbers. 
    2121    """ 
     22    default_error_messages = { 
     23        'invalid': ugettext("This field requires only numbers."), 
     24        'max_digits': ugettext("This field requires 8 digits."), 
     25    } 
     26 
    2227    def __init__(self, *args, **kwargs): 
    2328        super(PEDNIField, self).__init__(max_length=8, min_length=8, *args, 
     
    3237            return u'' 
    3338        if not value.isdigit(): 
    34             raise ValidationError(ugettext("This field requires only numbers.")
     39            raise ValidationError(self.error_messages['invalid']
    3540        if len(value) != 8: 
    36             raise ValidationError(ugettext("This field requires 8 digits.")
     41            raise ValidationError(self.error_messages['max_digits']
    3742 
    3843        return value 
     
    4348    the form XXXXXXXXXXX. 
    4449    """ 
     50    default_error_messages = { 
     51        'invalid': ugettext("This field requires only numbers."), 
     52        'max_digits': ugettext("This field requires 11 digits."), 
     53    } 
     54 
    4555    def __init__(self, *args, **kwargs): 
    4656        super(PERUCField, self).__init__(max_length=11, min_length=11, *args, 
     
    5565            return u'' 
    5666        if not value.isdigit(): 
    57             raise ValidationError(ugettext("This field requires only numbers.")
     67            raise ValidationError(self.error_messages['invalid']
    5868        if len(value) != 11: 
    59             raise ValidationError(ugettext("This field requires 11 digits.")
     69            raise ValidationError(self.error_messages['max_digits']
    6070        return value 
    6171