Aadhaar

object Aadhaar(source)

Validator, formatter, and masker for Aadhaar numbers issued by UIDAI.

Aadhaar is the 12-digit unique identity number issued by the Unique Identification Authority of India (UIDAI) to every Indian resident. It is required for:

  • Opening bank accounts (RBI KYC mandate)

  • Filing income tax returns

  • SIM card activation (TRAI mandate)

  • Government welfare benefit disbursement (DBT)

  • eKYC onboarding at regulated financial institutions

Format: 12 digits, first digit must be 2–9 (UIDAI never issues numbers starting with 0 or 1).

Checksum: Verhoeff algorithm (dihedral group D5). Implementation in io.github.kotindia.internal.Verhoeff — cross-referenced against Wikipedia D5 spec and mastermunj/format-utils JS implementation before finalising lookup tables.

Aadhaar is Private government-level PII protected under the Aadhaar Act 2016, IT Act 2000, and India's DPDP Act 2023. Always mask before logging or displaying. See mask for PII-safe display options.

Accepted input forms (all normalised before validation):

  • Raw: "234567890121"

  • UIDAI spaced: "2345 6789 0121" — spaces stripped before validation

  • Partial spacing: "2345 67890121" — stripped

  • Whitespace-padded: " 234567890121 " — trimmed + stripped

This object is stateless and thread-safe.

Samples

Aadhaar.validate("234567890124") // ValidationResult.Valid
Aadhaar.format("234567890124") // "2345 6789 0124"
Aadhaar.mask("234567890124") // "XXXXXXXX0124"

Functions

Link copied to clipboard
fun format(value: String): String

Formats a valid Aadhaar number to the UIDAI canonical spaced form.

Link copied to clipboard
fun isValid(value: String): Boolean

Returns true if validate returns ValidationResult.Valid.

Link copied to clipboard
fun mask(value: String, visibleStart: Int = 0, visibleEnd: Int = 4, maskChar: Char = 'X'): String

Masks an Aadhaar number for PII-safe display.

Link copied to clipboard

Validates an Aadhaar number.