RUT (Rol Único Tributario, Chilean national tax number).

The RUT, the Chilean national tax number is the same as the RUN (Rol Único Nacional) the Chilean national identification number. The number consists of 8 digits, followed by a check digit.

>>> validate('76086428-5')
>>> validate('CL 12531909-2')
>>> validate('12531909-3')
Traceback (most recent call last):
InvalidChecksum: ...
>>> validate('76086A28-5')
Traceback (most recent call last):
InvalidFormat: ...
>>> format('125319092')

Calculate the check digit. The number passed should not have the check digit included.

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 RUT.

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