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/au/forms.py

    r5876 r6926  
    1313class AUPostCodeField(RegexField): 
    1414    """Australian post code field.""" 
     15    default_error_messages = { 
     16        'invalid': ugettext('Enter a 4 digit post code.'), 
     17    } 
     18 
    1519    def __init__(self, *args, **kwargs): 
    1620        super(AUPostCodeField, self).__init__(r'^\d{4}$', 
    17             max_length=None, min_length=None, 
    18             error_message=ugettext('Enter a 4 digit post code.'), 
    19                     *args, **kwargs) 
     21            max_length=None, min_length=None, *args, **kwargs) 
    2022 
    2123class AUPhoneNumberField(Field): 
    2224    """Australian phone number field.""" 
     25    default_error_messages = { 
     26        'invalid': u'Phone numbers must contain 10 digits.', 
     27    } 
     28 
    2329    def clean(self, value): 
    2430        """ 
     
    3238        if phone_match: 
    3339            return u'%s' % phone_match.group(1) 
    34         raise ValidationError(u'Phone numbers must contain 10 digits.'
     40        raise ValidationError(self.error_messages['invalid']
    3541 
    3642class AUStateSelect(Select):