def validate(number): """Check if the number is a valid OIB number. This checks the length, formatting and check digit.""" number = compact(number) if not number.isdigit(): raise InvalidFormat() if len(number) != 11: raise InvalidLength() mod_11_10.validate(number) return number
def validate(number): """Check if the number is a valid OIB number. This checks the length, formatting and check digit.""" number = compact(number) if not isdigits(number): raise InvalidFormat() if len(number) != 11: raise InvalidLength() mod_11_10.validate(number) return number
def validate(number): """Check if the number provided is a valid VAT number. This checks the length, formatting and check digit.""" number = compact(number) if not number.isdigit() or number[0] == '0': raise InvalidFormat() if len(number) != 9: raise InvalidLength() mod_11_10.validate(number) return number
def validate(number): """Check if the number provided is a valid VAT number. This checks the length, formatting and check digit.""" number = compact(number) if not isdigits(number) or number[0] == '0': raise InvalidFormat() if len(number) != 9: raise InvalidLength() mod_11_10.validate(number) return number
def validate(number): """Check if the number provided is a valid tax identification number. This checks the length, formatting and check digit.""" number = compact(number) if len(number) != 11: raise InvalidLength() if not number.isdigit(): raise InvalidFormat() if number.startswith('0'): raise InvalidFormat() # In the first 10 digits exactly one digit must be repeated two or # three times and other digits can appear only once. counter = defaultdict(int) for n in number[:10]: counter[n] += 1 counts = [c for c in counter.values() if c > 1] if len(counts) != 1 or counts[0] not in (2, 3): raise InvalidFormat() return mod_11_10.validate(number)
def validate(number): """Check if the number provided is a valid tax identification number. This checks the length, formatting and check digit.""" number = compact(number) if len(number) != 11: raise InvalidLength() if not isdigits(number): raise InvalidFormat() if number.startswith('0'): raise InvalidFormat() # In the first 10 digits exactly one digit must be repeated two or # three times and other digits can appear only once. counter = defaultdict(int) for n in number[:10]: counter[n] += 1 counts = [c for c in counter.values() if c > 1] if len(counts) != 1 or counts[0] not in (2, 3): raise InvalidFormat() return mod_11_10.validate(number)
def test_mod11_10(self): sequence = self.get_sequence("ISO7064_11_10") self.assertTrue(mod_11_10.validate(sequence.next_by_id()))