'CNP validations'

def clean(self, value):

    value = super(ROCNPField, self).clean(value)
    if (value in EMPTY_VALUES):
        return u''
    try:
        datetime.date(int(value[1:3]), int(value[3:5]), int(value[5:7]))
    except ValueError:
        raise ValidationError(self.error_messages[u'invalid'])
    key = u'279146358279'
    checksum = 0
    value_iter = iter(value)
    for digit in key:
        checksum += (int(digit) * int(next(value_iter)))
    checksum %= 11
    if (checksum == 10):
        checksum = 1
    if (checksum != int(value[12])):
        raise ValidationError(self.error_messages[u'invalid'])
    return value
