validate
Validates an IMEI number.
Input normalisation applied before validation (in order):
Trim leading/trailing whitespace
Strip all internal whitespace (covers phone display form
"490 154 203 237 518")
Note on hyphens: Hyphens are NOT stripped — only whitespace is. Input containing hyphens (e.g. "490-154-203-237518") will return InvalidReason.INVALID_FORMAT. Callers must strip hyphens manually if their input may contain them.
After normalisation, checks are applied in this order — first failing check wins:
InvalidReason.EMPTY if the result is blank
InvalidReason.WRONG_LENGTH if normalised length is not 15
InvalidReason.INVALID_FORMAT if any non-digit character remains
InvalidReason.INVALID_CHECKSUM if the Luhn mod-10 checksum fails
No InvalidReason.INVALID_PREFIX check — IMEI has no first-digit restriction. TAC can start with any digit 0–9 per GSMA spec.
Return
ValidationResult.Valid if the IMEI passes all checks, ValidationResult.Invalid with an appropriate InvalidReason otherwise. Never throws.
Parameters
Raw IMEI string in any common input form.
Samples
check(IMEI.validate("356938035643809") == ValidationResult.Valid)