CNPJ (Cadastro Nacional da Pessoa Jurídica, Brazillian company identifier).

Numbers from the national register of legal entities have 14 digits. The first 8 digits identify the company, the following 4 digits identify a business unit and the last 2 digits are check digits.

>>> validate('16.727.230/0001-97')
>>> validate('16.727.230.0001-98')
Traceback (most recent call last):
InvalidChecksum: ...
>>> validate('16.727.230/0001=97')  # invalid delimiter
Traceback (most recent call last):
InvalidFormat: ...
>>> format('16727230000197')

Calculate the check digits for the number.

Convert the number to the minimal representation. This strips the number of any valid separators and removes surrounding whitespace.

Reformat the number to the standard presentation format.

Check if the number is a valid CNPJ.

Check if the number is a valid CNPJ. This checks the length and whether the check digits are correct.