UPN (English Unique Pupil Number).

The Unique Pupil Number (UPN) is a 13-character code that identifies pupils in English state schools and is designed to aid tracking pupil progress through the school system.

The number consists of a check letter, a 3-digit LA (Local Authority) number for the issuing school, a 4-digit DfE number (School Establishment Number), 2 digits for the issue year and 3 digits for a serial number. Temporary numbers have a 2-digit serial and a letter.

More information:

>>> validate('B801200005001')
>>> validate('A801200005001')
Traceback (most recent call last):
InvalidChecksum: ...
>>> validate('X80120000A001')  # middle part must be numeric
Traceback (most recent call last):
InvalidFormat: ...
>>> validate('E000200005001')  # LA number must be known
Traceback (most recent call last):
InvalidComponent: ...

Calculate the check digit for the number.

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

Check if the number is a valid UPN. This checks length, formatting and check digits.