| 3977 | # BRZipCodeField ############################################################ |
| 3978 | >>> from django.contrib.localflavor.br.forms import BRZipCodeField |
| 3979 | >>> f = BRZipCodeField() |
| 3980 | >>> f.clean('12345-123') |
| 3981 | u'12345-123' |
| 3982 | >>> f.clean('12345_123') |
| 3983 | Traceback (most recent call last): |
| 3984 | ... |
| 3985 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 3986 | >>> f.clean('1234-123') |
| 3987 | Traceback (most recent call last): |
| 3988 | ... |
| 3989 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 3990 | >>> f.clean('abcde-abc') |
| 3991 | Traceback (most recent call last): |
| 3992 | ... |
| 3993 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 3994 | >>> f.clean('12345-') |
| 3995 | Traceback (most recent call last): |
| 3996 | ... |
| 3997 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 3998 | >>> f.clean('-123') |
| 3999 | Traceback (most recent call last): |
| 4000 | ... |
| 4001 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 4002 | >>> f.clean('') |
| 4003 | Traceback (most recent call last): |
| 4004 | ... |
| 4005 | ValidationError: [u'This field is required.'] |
| 4006 | >>> f.clean(None) |
| 4007 | Traceback (most recent call last): |
| 4008 | ... |
| 4009 | ValidationError: [u'This field is required.'] |
| 4010 | |
| 4011 | >>> f = BRZipCodeField(required=False) |
| 4012 | >>> f.clean(None) |
| 4013 | u'' |
| 4014 | >>> f.clean('') |
| 4015 | u'' |
| 4016 | >>> f.clean('-123') |
| 4017 | Traceback (most recent call last): |
| 4018 | ... |
| 4019 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 4020 | >>> f.clean('12345-') |
| 4021 | Traceback (most recent call last): |
| 4022 | ... |
| 4023 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 4024 | >>> f.clean('abcde-abc') |
| 4025 | Traceback (most recent call last): |
| 4026 | ... |
| 4027 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 4028 | >>> f.clean('1234-123') |
| 4029 | Traceback (most recent call last): |
| 4030 | ... |
| 4031 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 4032 | >>> f.clean('12345_123') |
| 4033 | Traceback (most recent call last): |
| 4034 | ... |
| 4035 | ValidationError: [u'Informe um c\xf3digo postal no formato XXXXX-XXX.'] |
| 4036 | >>> f.clean('12345-123') |
| 4037 | u'12345-123' |
| 4038 | |
| 4039 | # BRPhoneNumberField ######################################################### |
| 4040 | |
| 4041 | >>> from django.contrib.localflavor.br.forms import BRPhoneNumberField |
| 4042 | >>> f = BRPhoneNumberField() |
| 4043 | >>> f.clean('41-3562-3464') |
| 4044 | u'41-3562-3464' |
| 4045 | >>> f.clean('4135623464') |
| 4046 | u'41-3562-3464' |
| 4047 | >>> f.clean('41 3562-3464') |
| 4048 | u'41-3562-3464' |
| 4049 | >>> f.clean('41 3562 3464') |
| 4050 | u'41-3562-3464' |
| 4051 | >>> f.clean('(41) 3562 3464') |
| 4052 | u'41-3562-3464' |
| 4053 | >>> f.clean('41.3562.3464') |
| 4054 | u'41-3562-3464' |
| 4055 | >>> f.clean('41.3562-3464') |
| 4056 | u'41-3562-3464' |
| 4057 | >>> f.clean(' (41) 3562.3464') |
| 4058 | u'41-3562-3464' |
| 4059 | >>> f.clean(None) |
| 4060 | Traceback (most recent call last): |
| 4061 | ... |
| 4062 | ValidationError: [u'This field is required.'] |
| 4063 | >>> f.clean('') |
| 4064 | Traceback (most recent call last): |
| 4065 | ... |
| 4066 | ValidationError: [u'This field is required.'] |
| 4067 | |
| 4068 | >>> f = BRPhoneNumberField(required=False) |
| 4069 | >>> f.clean('') |
| 4070 | u'' |
| 4071 | >>> f.clean(None) |
| 4072 | u'' |
| 4073 | >>> f.clean(' (41) 3562.3464') |
| 4074 | u'41-3562-3464' |
| 4075 | >>> f.clean('41.3562-3464') |
| 4076 | u'41-3562-3464' |
| 4077 | >>> f.clean('(41) 3562 3464') |
| 4078 | u'41-3562-3464' |
| 4079 | >>> f.clean('4135623464') |
| 4080 | u'41-3562-3464' |
| 4081 | >>> f.clean('41 3562-3464') |
| 4082 | u'41-3562-3464' |
| 4083 | |
| 4084 | # BRStateSelect ############################################################## |
| 4085 | |
| 4086 | >>> from django.contrib.localflavor.br.forms import BRStateSelect |
| 4087 | >>> w = BRStateSelect() |
| 4088 | >>> w.render('states', 'PR') |
| 4089 | u'<select name="states">\n<option value="AC">Acre</option>\n<option value="AL">Alagoas</option>\n<option value="AP">Amap\xe1</option>\n<option value="AM">Amazonas</option>\n<option value="BA">Bahia</option>\n<option value="CE">Cear\xe1</option>\n<option value="DF">Distrito Federal</option>\n<option value="ES">Esp\xedrito Santo</option>\n<option value="GO">Goi\xe1s</option>\n<option value="MA">Maranh\xe3o</option>\n<option value="MT">Mato Grosso</option>\n<option value="MS">Mato Grosso do Sul</option>\n<option value="MG">Minas Gerais</option>\n<option value="PA">Par\xe1</option>\n<option value="PB">Para\xedba</option>\n<option value="PR" selected="selected">Paran\xe1</option>\n<option value="PE">Pernambuco</option>\n<option value="PI">Piau\xed</option>\n<option value="RJ">Rio de Janeiro</option>\n<option value="RN">Rio Grande do Norte</option>\n<option value="RS">Rio Grande do Sul</option>\n<option value="RO">Rond\xf4nia</option>\n<option value="RR">Roraima</option>\n<option value="SC">Santa Catarina</option>\n<option value="SP">S\xe3o Paulo</option>\n<option value="SE">Sergipe</option>\n<option value="TO">Tocantins</option>\n</select>' |
| 4090 | |