validate
Validates an Indian Tax Deduction Account Number (TAN).
Input normalisation applied before validation (in order):
Trim leading/trailing whitespace
Strip all internal whitespace (covers copy-paste with spaces)
Uppercase all characters
After normalisation, checks are applied in order — first failing check wins:
InvalidReason.EMPTY if the result is blank
InvalidReason.WRONG_LENGTH if length is not 10
InvalidReason.INVALID_FORMAT if the string does not match
^[A-Z]{4}[0-9]{5}[A-Z]$
The regex encodes all structural constraints simultaneously:
Characters 1–4 must be
[A-Z]Characters 5–9 must be
[0-9]Character 10 must be
[A-Z]
Note: Hyphens and other special characters are not stripped. "MUMD-2345A" normalises to a 10-character string but fails regex and returns InvalidReason.INVALID_FORMAT.
Return
ValidationResult.Valid if the code is a valid TAN, ValidationResult.Invalid with an appropriate InvalidReason otherwise.
Parameters
Raw TAN string in any common input form.
Samples
check(TAN.validate("PDES03028F") == ValidationResult.Valid)