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')
'760864285'
>>> validate('CL 12531909-2')
'125319092'
>>> validate('12531909-3')
Traceback (most recent call last):
...
InvalidChecksum: ...
>>> validate('76086A28-5')
Traceback (most recent call last):
...
InvalidFormat: ...
>>> format('125319092')
'12.531.909-2'
Traceback (most recent call last):
...
InvalidFormat: ...
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 passed number to the standard format.
Checks to see if the number provided is a valid number. This checks the length, formatting and check digit.
Checks to see if the number provided is a valid number. This checks the length, formatting and check digit.