Invalid Reason
The reason a validator returned ValidationResult.Invalid.
Each value identifies the specific validation failure that was detected. Callers switching on InvalidReason should use an else branch to remain forward-compatible with new values added in future releases.
val result = PAN.validate("ABCDE1234F")
if (result is ValidationResult.Invalid) {
when (result.reason) {
InvalidReason.EMPTY -> showError("Input is empty")
InvalidReason.WRONG_LENGTH -> showError("Wrong number of characters")
InvalidReason.INVALID_FORMAT -> showError("Invalid character pattern")
else -> showError("Validation failed: ${result.reason}")
}
}Samples
val result = Aadhaar.validate("000000000000")
check(result is ValidationResult.Invalid)
check(result.reason == InvalidReason.INVALID_PREFIX)Entries
Input has the wrong character count for this document type (e.g., PAN must be exactly 10 chars).
Input does not match the required character pattern (regex) for this document type.
Input fails the document-specific checksum algorithm (Verhoeff for Aadhaar, Luhn for IMEI, GSTN for GSTIN).
Input has an unrecognised prefix (e.g., pincode starting with 0, mobile not starting with 6–9).
Input encodes an invalid category code (e.g., PAN 4th character not in {P, C, H, A, B, G, J, L, F, T}).
Properties
Functions
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Returns an array containing the constants of this enum type, in the order they're declared.