validate
Validates an Aadhaar number.
Input normalisation applied before validation (in order):
Trim leading/trailing whitespace
Strip all internal whitespace (covers UIDAI spaced
"1234 5678 9012"form)
After normalisation, checks are applied in this order — first failing check wins:
InvalidReason.EMPTY if the result is blank
InvalidReason.WRONG_LENGTH if length is not 12
InvalidReason.INVALID_FORMAT if any non-digit character remains
InvalidReason.INVALID_PREFIX if the first digit is 0 or 1
InvalidReason.INVALID_CHECKSUM if the Verhoeff checksum fails
Return
ValidationResult.Valid if the Aadhaar passes all checks, ValidationResult.Invalid with an appropriate InvalidReason otherwise. Never throws.
Parameters
value
Raw Aadhaar string in any common input form.
Samples
check(Aadhaar.validate("234567890124") == ValidationResult.Valid)
check(Aadhaar.validate("") is ValidationResult.Invalid)Content copied to clipboard