IMEI

object IMEI(source)

Validator, formatter, and masker for IMEI numbers assigned by the GSMA.

IMEI (International Mobile Equipment Identity) is the unique 15-digit identifier assigned to every mobile device globally by the GSMA (Global System for Mobile Communications Association). IMEI is used for:

  • Device blacklisting by carriers when stolen or lost (GSMA IMEI database / CEIR in India)

  • SIM-lock and network unlock verification

  • Device identity in telecom KYC flows (TRAI DoT mandate)

  • Regulatory filings — all mobile device imports to India require IMEI registration with DoT

  • Warranty and insurance claims (device identity verification)

Format: 15 digits. Last digit is the Luhn mod-10 check digit. First 8 digits = TAC (Type Allocation Code) — format-only validation, no GSMA database lookup. Next 6 digits = serial number. No first-digit restriction (unlike Aadhaar or Mobile).

Checksum: Luhn algorithm (ISO/IEC 7812 / mod-10). Implementation in io.github.kotindia.internal.Luhn — cross-referenced against Wikipedia Luhn specification and npm luhn package (MIT) before finalizing.

IMEI is Device PII — it uniquely identifies a physical device (Telecom Cybersecurity Rules, 2024). Always mask before logging or displaying. See mask for PII-safe display.

Accepted input forms (all normalised before validation):

  • Raw: "490154203237518"

  • Phone display form: "490 154 203 237 518" — internal spaces stripped before validation

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

  • Hyphens are NOT stripped — "490-154-203-237518"INVALID_FORMAT

This object is stateless and thread-safe.

Samples

IMEI.validate("356938035643809") // ValidationResult.Valid
IMEI.format("356938035643809") // "356938035643809"
IMEI.mask("356938035643809") // "XXXXXXXXXXX3809"

Functions

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

Formats a valid IMEI number to its canonical 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 IMEI number for PII-safe display.

Link copied to clipboard

Validates an IMEI number.