DL

object DL(source)

Validator, formatter, and masker for Indian Driving License (DL) numbers.

A Driving License is the state-issued motor vehicle permit in India, governed by the Motor Vehicles Act 1988 and administered by state RTOs through the MoRTH Sarathi Parivahan portal (https://parivahan.gov.in/parivahan/).

Supported format

Phase 1 supports the POST-2013 Sarathi Parivahan standard format ONLY.

Structure (after normalisation — see below):

  • Characters 0–1: 2-letter state/UT code (e.g. MH, DL, KA) — closed list of 38 valid codes

  • Characters 2–2 or 2–3: RTO code — 1 or 2 digits (state-assigned)

  • Characters 3–13 or 4–14: 4-digit year of issue + 7-digit serial — 11 digits total

  • Total normalised length: 14 (1-digit RTO) or 15 (2-digit RTO)

Examples of valid inputs:

Raw inputNormalisedNotes
"MH1220110012345""MH1220110012345"Maharashtra, 2-digit RTO
"MH12-20110012345""MH1220110012345"Hyphen separator (Digilocker format)
"MH12 20110012345""MH1220110012345"Space separator
"mh1220110012345""MH1220110012345"Lowercase
"DL-5-2016-0012345""DL520160012345"Delhi, 1-digit RTO

State codes accepted: AN AP AR AS BR CG CH DD DL DN GA GJ HP HR JH JK KA KL LA LD MH ML MN MP MZ NL OD OR PB PY RJ SK TN TR TS UK UP WB (38 total).

  • LA — Ladakh, added as a UT in 2019 (post-reorganisation).

  • OD — Odisha current official code (post-2011).

  • OR — Odisha legacy ISO code (pre-2011). Existing DLs issued with OR remain valid.

Documented limitation (R4 — DL format diversity)

Pre-2013 state-specific Sarathi formats are EXPLICITLY NOT SUPPORTED in Phase 1.

Before the Sarathi Parivahan portal standardised the DL numbering scheme in 2013, each of India's 36 states and UTs issued DLs in their own format — different lengths, separator conventions, and character arrangements. These historical formats are diverse, undocumented in any canonical public spec, and largely still in circulation on physically printed DL cards that predate the portal.

Inputs matching pre-2013 patterns will return:

Pre-2013 format examples that are rejected:

  • "MH-12-345678" — old Maharashtra format (~12 chars after strip)

  • "DL-7-2003-0123456" — old Delhi format with different RTO placement

  • "TN-25-XXYY1234" — old Tamil Nadu alphanumeric format

Source: MoRTH Sarathi Parivahan portal (https://sarathi.parivahan.gov.in/). Format decisions are based on the post-2013 Sarathi-issued DL numbering standard documented at the Sarathi portal and cross-referenced with Digilocker DL data format.

No Sarathi portal lookup is performed. Validation is structural only — DL validity, holder name, vehicle categories, and suspension status require a live government API call, which is explicitly out of scope for this library.

DL is a Private government ID (Photo ID + address proof). Mask before logging or display. See mask for PII-safe display options.

This object is stateless and thread-safe.

Samples

DL.validate("MH0120230012345") // ValidationResult.Valid
DL.format("MH0120230012345") // "MH0120230012345"
DL.mask("MH0120230012345") // "XXXXXXXXXXX2345"

Functions

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

Formats a valid Driving License 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 a Driving License number for PII-safe display.

Link copied to clipboard

Validates an Indian Driving License number.