VAT (United Kingdom (and Isle of Man) VAT registration number).
The VAT number can either be a 9-digit standard number, a 12-digit standard number followed by a 3-digit branch identifier, a 5-digit number for government departments (first two digits are GD) or a 5-digit number for health authorities (first two digits are HA). The 9-digit variants use a weighted checksum.
>>> validate('GB 980 7806 84')
'980780684'
>>> validate('802311781') # invalid check digit
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> format('980780684')
'980 7806 84'
Traceback (most recent call last):
...
InvalidChecksum: ...
Calculate the checksum. The checksum is only used for the 9 digits of the number and the result can either be 0 or 42.
Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.
Reformat the passed number to the standard format.
Checks to see if the number provided is a valid VAT number. This checks the length, formatting and check digit.
Checks to see if the number provided is a valid VAT number. This checks the length, formatting and check digit.