'Value can be either a string in the format XXX.XXX.XXX-XX or an
11-digit number.'

def clean(self, value):

    value = super(BRCPFField, self).clean(value)
    if (value in EMPTY_VALUES):
        return u''
    orig_value = value[:]
    if (not value.isdigit()):
        value = re.sub(u'[-\\.]', u'', value)
    try:
        int(value)
    except ValueError:
        raise ValidationError(self.error_messages[u'digits_only'])
    if (len(value) != 11):
        raise ValidationError(self.error_messages[u'max_digits'])
    orig_dv = value[(-2):]
    new_1dv = sum([(i * int(value[idx])) for (idx, i) in enumerate(range(10, 1, (-1)))])
    new_1dv = DV_maker((new_1dv % 11))
    value = ((value[:(-2)] + str(new_1dv)) + value[(-1)])
    new_2dv = sum([(i * int(value[idx])) for (idx, i) in enumerate(range(11, 1, (-1)))])
    new_2dv = DV_maker((new_2dv % 11))
    value = (value[:(-1)] + str(new_2dv))
    if (value[(-2):] != orig_dv):
        raise ValidationError(self.error_messages[u'invalid'])
    return orig_value
