Ticket #5871: localflavor.nl.error_mesages.diff
File localflavor.nl.error_mesages.diff, 3.3 KB (added by , 17 years ago) |
---|
-
django/contrib/localflavor/nl/forms.py
22 22 if value in EMPTY_VALUES: 23 23 return u'' 24 24 25 msg = _('Enter a valid postal code')26 25 value = value.strip().upper().replace(' ', '') 27 26 if not pc_re.search(value): 28 raise ValidationError( msg)27 raise ValidationError(self.error_messages['required']) 29 28 30 29 if int(value[:4]) < 1000: 31 raise ValidationError( msg)30 raise ValidationError(self.error_messages['required']) 32 31 33 32 return u'%s %s' % (value[:4], value[4:]) 34 33 … … 50 49 if value in EMPTY_VALUES: 51 50 return u'' 52 51 53 msg = _('Enter a valid phone number')54 52 phone_nr = re.sub('[\-\s\(\)]', '', smart_unicode(value)) 55 53 56 54 if len(phone_nr) == 10 and numeric_re.search(phone_nr): … … 60 58 numeric_re.search(phone_nr[3:]): 61 59 return value 62 60 63 raise ValidationError( msg)61 raise ValidationError(self.error_messages['required']) 64 62 65 63 class NLSoFiNumberField(Field): 66 64 """ … … 73 71 if value in EMPTY_VALUES: 74 72 return u'' 75 73 76 msg = _('Enter a valid SoFi number')77 78 74 if not sofi_re.search(value): 79 raise ValidationError( msg)75 raise ValidationError(self.error_messages['required']) 80 76 81 77 if int(value) == 0: 82 raise ValidationError( msg)78 raise ValidationError(self.error_messages['required']) 83 79 84 80 checksum = 0 85 81 for i in range(9, 1, -1): … … 87 83 checksum -= int(value[-1]) 88 84 89 85 if checksum % 11 != 0: 90 raise ValidationError( msg)86 raise ValidationError(self.error_messages['required']) 91 87 92 88 return value -
tests/regressiontests/forms/localflavor/nl.py
5 5 # NLPhoneNumberField ######################################################## 6 6 7 7 >>> from django.contrib.localflavor.nl.forms import NLPhoneNumberField 8 >>> f = NLPhoneNumberField(required=False )8 >>> f = NLPhoneNumberField(required=False, error_messages={'required':'Enter a valid phone number'}) 9 9 >>> f.clean('') 10 10 u'' 11 11 >>> f.clean('012-3456789') … … 24 24 # NLZipCodeField ############################################################ 25 25 26 26 >>> from django.contrib.localflavor.nl.forms import NLZipCodeField 27 >>> f = NLZipCodeField(required=False )27 >>> f = NLZipCodeField(required=False, error_messages={'required':'Enter a valid postal code'}) 28 28 >>> f.clean('') 29 29 u'' 30 30 >>> f.clean('1234ab') … … 45 45 # NLSoFiNumberField ######################################################### 46 46 47 47 >>> from django.contrib.localflavor.nl.forms import NLSoFiNumberField 48 >>> f = NLSoFiNumberField(required=False )48 >>> f = NLSoFiNumberField(required=False, error_messages={'required':'Enter a valid SoFi number'}) 49 49 >>> f.clean('') 50 50 u'' 51 51 >>> f.clean('123456782')