Skip to main content
Parse Iranian license plates into structured info: type (car/motorcycle), category (شخصی, دولتی, دیپلمات, …), province, and a formatted template string. Validation is included in the same call.
The library exports plain functions. There is no Numberplate class.

Functions

getNumberPlateInfo(plate)

Main API. Accepts either a compact string or an object.

Lower-level pieces

getNumberPlateInfo is the composition of getPlateInfo + isPlateValid over a normalized plate.

Result shape

  • info.type is the string "Car" or "Motorcycle" — not a Persian category.
  • info.category (cars only) is the Persian category ("شخصی", "دولتی", "دیپلمات", …).
  • info.template is a presentation-ready string.
  • info.details is the parsed sub-fields (see types below).

Input shapes

  • String for compact plates: "12D45147" (car) or "12345678" (motorcycle).
  • Object when the Persian letter is separated: { number: "1245147", char: "ج" }.

Types

Validation rules

For cars, isPlateValid requires:
  • The plate digits must be [1-9] only (no 0).
  • The category from info.category must be resolved (i.e., the letter + province code combination is known).
For motorcycles:
  • 8-digit numeric input.

Pitfalls

  • No Numberplate class. Don’t new Numberplate(...). Call the plain functions.
  • info.type is English ("Car" / "Motorcycle"). Persian categorization lives in info.category.
  • Province codes are data-driven — see src/modules/numberplate/codes.skip.ts.
  • Plates containing 0 are rejected by isPlateNumberValid — matches real-world rules.

Source

src/modules/numberplate/index.ts, helpers.ts, codes.skip.ts, types.skip.ts · Tests: test/numberplate.spec.ts