validate
Validates an Indian Permanent Account Number (PAN).
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]{5}[0-9]{4}[A-Z]$InvalidReason.INVALID_CATEGORY if the 4th character (index 3) is not one of:
P(Person),C(Company),H(HUF),A(AOP),B(BOI),G(Government),J(Artificial Juridical Person),L(Local Authority),F(Firm),T(Trust)
Note: Hyphens are not stripped. "ABCPE-1234F" normalises to 11 characters and returns InvalidReason.WRONG_LENGTH.
Return
ValidationResult.Valid if the PAN passes format and category validation, ValidationResult.Invalid with an appropriate InvalidReason otherwise.
Parameters
Raw PAN string in any common input form.
Samples
check(PAN.validate("ABCPE1234F") == ValidationResult.Valid)
check(PAN.validate("ABCZE1234F") is ValidationResult.Invalid)