# Vehicle plates

> Split a Pakistani vehicle registration number into series letters, number and optional year, and check its common shape.

Source: https://pakdatakit.dev/docs/vehicle/

`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`).

> **There is no single national format**
>
> Each province's excise department sets its own format, and several changed in 2024 to 2026 (numbers that stay with the owner, new series). This checks the common shape shared by all of them.
## Examples

**TypeScript**

```ts
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
```

**Python**

```python
from 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')
# → False
```

**Dart**

```dart
import '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');
// → false
```

**C#**

```csharp
using 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");
// → false
```

**PHP**

```php
use 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');
// → false
```

## Reference

### parseVehiclePlate()

```ts
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).

### validateVehiclePlate()

```ts
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()`](#parsevehicleplate).

## Related

- [CNIC](https://pakdatakit.dev/docs/cnic/), [NTN and STRN](https://pakdatakit.dev/docs/tax/), [passport](https://pakdatakit.dev/docs/passport/).
- [API reference for `pakdatakit/vehicle`](https://pakdatakit.dev/api/typescript/vehicle/).
