Changeset 6926 for django/trunk/django/contrib/localflavor/za
- Timestamp:
- 12/17/07 02:05:27 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/contrib/localflavor/za/forms.py
r6843 r6926 17 17 check for the birthdate 18 18 """ 19 20 def __init__(self, *args, **kwargs): 21 super(ZAIDField, self).__init__() 22 self.error_message = _(u'Enter a valid South African ID number') 19 default_error_messages = { 20 'invalid': _(u'Enter a valid South African ID number'), 21 } 23 22 24 23 def clean(self, value): … … 32 31 33 32 match = re.match(id_re, value) 34 33 35 34 if not match: 36 raise ValidationError(self.error_message )35 raise ValidationError(self.error_messages['invalid']) 37 36 38 37 g = match.groupdict() … … 44 43 d = date(int(g['yy']) + 2000, int(g['mm']), int(g['dd'])) 45 44 except ValueError: 46 raise ValidationError(self.error_message )45 raise ValidationError(self.error_messages['invalid']) 47 46 48 47 if not luhn(value): 49 raise ValidationError(self.error_message )48 raise ValidationError(self.error_messages['invalid']) 50 49 51 50 return value 52 51 53 52 class ZAPostCodeField(RegexField): 53 default_error_messages = { 54 'invalid': _(u'Enter a valid South African postal code'), 55 } 56 54 57 def __init__(self, *args, **kwargs): 55 58 super(ZAPostCodeField, self).__init__(r'^\d{4}$', 56 max_length=None, min_length=None, 57 error_message=_(u'Enter a valid South African postal code')) 59 max_length=None, min_length=None)
