AadhaarVID

Validator, formatter, and masker for Aadhaar Virtual IDs (VID) issued by UIDAI.

AadhaarVID is a 16-digit revocable identifier introduced by UIDAI in 2018, allowing residents to share a privacy-safe proxy for their Aadhaar number without revealing the underlying 12-digit Aadhaar. Used in eKYC flows where the full Aadhaar is not required.

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

Checksum: Same Verhoeff algorithm as Aadhaar. Implementation in io.github.kotindia.internal.Verhoeff.

AadhaarVID is Private government-level PII — same legal protection as Aadhaar (Aadhaar Act 2016, IT Act 2000, DPDP Act 2023). Always mask before logging or displaying. See mask for PII-safe display options.

Accepted input forms (all normalised before validation):

  • Raw: "2345678901234561"

  • Spaced: "2345 6789 0123 4561" — spaces stripped before validation

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

This object is stateless and thread-safe.

Samples

AadhaarVID.validate("2345678901240000") // ValidationResult.Valid (Verhoeff valid VID)
AadhaarVID.format("2345678901240000") // "2345 6789 0124 0000"
AadhaarVID.mask("2345678901240000") // "XXXXXXXXXXXX0000"

Functions

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

Formats a valid AadhaarVID to the 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 AadhaarVID for PII-safe display.

Link copied to clipboard

Validates an Aadhaar Virtual ID.