n° TVA (taxe sur la valeur ajoutée, French VAT number).

The n° TVA (Numéro d’identification à la taxe sur la valeur ajoutée) is the SIREN (Système d’Identification du Répertoire des Entreprises) prefixed by two digits. In old style numbers the two digits are numeric, with new style numbers at least one is a alphabetic.

>>> compact('Fr 40 303 265 045')
>>> validate('23334175221')
>>> validate('84 323 140 391')
Traceback (most recent call last):
InvalidChecksum: ...
>>> validate('K7399859412')  # new-style number
>>> validate('4Z123456782')  # new-style number starting with digit
>>> validate('IO334175221')   # the letters cannot by I or O
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.

Check if the number is a valid VAT number.

Check if the number is a valid VAT number. This checks the length, formatting and check digit.