| 803 | # BRCPFField ################################################################# |
| 804 | |
| 805 | >>> from django.contrib.localflavor.br.forms import BRCPFField |
| 806 | >>> f = BRCPFField() |
| 807 | >>> f.clean('') |
| 808 | Traceback (most recent call last): |
| 809 | ... |
| 810 | ValidationError: [u'This field is required.'] |
| 811 | >>> f.clean(None) |
| 812 | Traceback (most recent call last): |
| 813 | ... |
| 814 | ValidationError: [u'This field is required.'] |
| 815 | >>> f.clean('489.294.654-54') |
| 816 | Traceback (most recent call last): |
| 817 | ... |
| 818 | ValidationError: [u'Invalid CPF number.'] |
| 819 | >>> f.clean('295.669.575-98') |
| 820 | Traceback (most recent call last): |
| 821 | ... |
| 822 | ValidationError: [u'Invalid CPF number.'] |
| 823 | >>> f.clean('539.315.127-22') |
| 824 | Traceback (most recent call last): |
| 825 | ... |
| 826 | ValidationError: [u'Invalid CPF number.'] |
| 827 | >>> f.clean('663.256.017-26') |
| 828 | u'663.256.017-26' |
| 829 | >>> f.clean('66325601726') |
| 830 | u'66325601726' |
| 831 | >>> f.clean('375.788.573-20') |
| 832 | u'375.788.573-20' |
| 833 | >>> f.clean('84828509895') |
| 834 | u'84828509895' |
| 835 | >>> f.clean('375.788.573-XX') |
| 836 | Traceback (most recent call last): |
| 837 | ... |
| 838 | ValidationError: [u'This field requires only numbers'] |
| 839 | >>> f.clean('375.788.573-000') |
| 840 | Traceback (most recent call last): |
| 841 | ... |
| 842 | ValidationError: [u'Ensure this value has at most 14 characters.'] |
| 843 | >>> f.clean('123.456.78') |
| 844 | Traceback (most recent call last): |
| 845 | ... |
| 846 | ValidationError: [u'Ensure this value has at least 11 characters.'] |
| 847 | >>> f.clean('123456789555') |
| 848 | Traceback (most recent call last): |
| 849 | ... |
| 850 | ValidationError: [u'This field requires at most 11 digits or 14 characters.'] |
| 851 | >>> f = BRCPFField(required=False) |
| 852 | >>> f.clean('') |
| 853 | u'' |
| 854 | >>> f.clean(None) |
| 855 | u'' |
| 856 | |