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.typeis the string"Car"or"Motorcycle"— not a Persian category.info.category(cars only) is the Persian category ("شخصی","دولتی","دیپلمات", …).info.templateis a presentation-ready string.info.detailsis 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 (no0). - The category from
info.categorymust be resolved (i.e., the letter + province code combination is known).
- 8-digit numeric input.
Pitfalls
- No
Numberplateclass. Don’tnew Numberplate(...). Call the plain functions. info.typeis English ("Car"/"Motorcycle"). Persian categorization lives ininfo.category.- Province codes are data-driven — see
src/modules/numberplate/codes.skip.ts. - Plates containing
0are rejected byisPlateNumberValid— matches real-world rules.
Source
src/modules/numberplate/index.ts, helpers.ts, codes.skip.ts, types.skip.ts · Tests: test/numberplate.spec.ts