InvalidReason

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

Link copied to clipboard

Input is blank or empty — validator received "" or a whitespace-only string.

Link copied to clipboard

Input has the wrong character count for this document type (e.g., PAN must be exactly 10 chars).

Link copied to clipboard

Input does not match the required character pattern (regex) for this document type.

Link copied to clipboard

Input fails the document-specific checksum algorithm (Verhoeff for Aadhaar, Luhn for IMEI, GSTN for GSTIN).

Link copied to clipboard

Input has an unrecognised prefix (e.g., pincode starting with 0, mobile not starting with 6–9).

Link copied to clipboard

Input encodes an invalid category code (e.g., PAN 4th character not in {P, C, H, A, B, G, J, L, F, T}).

Properties

Link copied to clipboard

Returns a representation of an immutable list of all enum entries, in the order they're declared.

Link copied to clipboard
expect val name: String
Link copied to clipboard
expect val ordinal: Int

Functions

Link copied to clipboard

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

Link copied to clipboard

Returns an array containing the constants of this enum type, in the order they're declared.