Skip to content

Vehicle plates

import { parseVehiclePlate, validateVehiclePlate } from 'pakdatakit/vehicle'

Splits a vehicle registration number into its series letters, number and optional year, such as LEA-1234 or ABC 123. It accepts the common shape: 1 to 4 letters, then 1 to 4 digits, optionally followed by the two-digit year that older Punjab plates carry (LEA-1234-19).

parseVehiclePlate() Valid

Series
LEA
Number
1234
Year
—
Formatted
LEA-1234
import { parseVehiclePlate, validateVehiclePlate } from 'pakdatakit';
parseVehiclePlate('lea 1234');
// → {
// "series": "LEA",
// "number": "1234",
// "year": null,
// "formatted": "LEA-1234"
// }
parseVehiclePlate('LEA-1234-19');
// → {
// "series": "LEA",
// "number": "1234",
// "year": "19",
// "formatted": "LEA-1234"
// }
validateVehiclePlate('ABC 123');
// → true
validateVehiclePlate('12345');
// → false
function parseVehiclePlate(plate: string): VehiclePlate | null;
interface VehiclePlate {
series: string; // letters before the number, e.g. LEA
number: string; // digits of the registration number, e.g. 1234
year: string | null; // two-digit year on some older Punjab plates
formatted: string; // LEA-1234 (without the year)
}

Parameters. plate: the registration number as written on the plate. Pass the registration number only, without labels such as “ICT” or “PUNJAB” printed elsewhere on the plate.

Returns the parts, or null when the input does not have the common shape.

Caveats. Series letters are not checked against a list of districts, as no official list is published.

Related: validateVehiclePlate().

function validateVehiclePlate(plate: string): boolean;

Parameters. plate: as for parseVehiclePlate().

Returns true when the registration number has the common shape. It checks the common shape only.

Related: parseVehiclePlate().