CIF (Certificado de Identificación Fiscal, Spanish company tax number).
The CIF is a tax identification number for legal entities. It has 9 digits where the first digit is a letter (denoting the type of entity) and the last is a check digit (which may also be a letter).
>>> validate('J99216582')
'J99216582'
>>> validate('J99216583') # invalid check digit
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> validate('J992165831') # too long
Traceback (most recent call last):
...
InvalidLength: ...
>>> validate('M-1234567-L')
'M1234567L'
>>> validate('O-1234567-L') # invalid first character
Traceback (most recent call last):
...
InvalidFormat: ...
>>> split('A13 585 625')
('A', '13', '58562', '5')
Traceback (most recent call last):
...
InvalidFormat: ...
Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.
Checks to see if the number provided is a valid DNI number. This checks the length, formatting and check digit.
Checks to see if the number provided is a valid DNI number. This checks the length, formatting and check digit.
Split the provided number into a letter to define the type of organisation, two digits that specify a province, a 5 digit sequence number within the province and a check digit.