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
Examples
Section titled “Examples”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');// → falsefrom pakdatakit import parse_vehicle_plate, validate_vehicle_plate
parse_vehicle_plate('lea 1234')# → {# "series": "LEA",# "number": "1234",# "year": None,# "formatted": "LEA-1234"# }
parse_vehicle_plate('LEA-1234-19')# → {# "series": "LEA",# "number": "1234",# "year": "19",# "formatted": "LEA-1234"# }
validate_vehicle_plate('ABC 123')# → True
validate_vehicle_plate('12345')# → Falseimport 'package:pakdatakit/pakdatakit.dart';
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');// → falseusing PakDataKit;
VehiclePlate.Parse("lea 1234");// → {// "series": "LEA",// "number": "1234",// "year": null,// "formatted": "LEA-1234"// }
VehiclePlate.Parse("LEA-1234-19");// → {// "series": "LEA",// "number": "1234",// "year": "19",// "formatted": "LEA-1234"// }
VehiclePlate.Validate("ABC 123");// → true
VehiclePlate.Validate("12345");// → falseuse PakDataKit\VehiclePlate;
VehiclePlate::parse('lea 1234');// → {// "series": "LEA",// "number": "1234",// "year": null,// "formatted": "LEA-1234"// }
VehiclePlate::parse('LEA-1234-19');// → {// "series": "LEA",// "number": "1234",// "year": "19",// "formatted": "LEA-1234"// }
VehiclePlate::validate('ABC 123');// → true
VehiclePlate::validate('12345');// → falseReference
Section titled “Reference”parseVehiclePlate()
Section titled “parseVehiclePlate()”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().
validateVehiclePlate()
Section titled “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().