Utility Bills & Vehicles

Validate and extract metadata from Iranian license plates and utility bills (Water, Electricity, Gas, etc.).

Validation with Zod

Ensure the mathematical correctness of bill IDs and validate license plates supporting varied formats.

schema.ts
typescript
import * as z from 'zod';
import { zPlateNumber, zBillId, zPaymentId } from 'zod-ir';

const UtilitySchema = z.object({
  plate: zPlateNumber({ message: 'پلاک خودرو معتبر نیست' }),
  billId: zBillId({ message: 'شناسه قبض اشتباه است' }),
  paymentId: zPaymentId({ message: 'شناسه پرداخت اشتباه است' }),
});

Metadata Extraction (Standalone)

Extract the issuing province of a plate, or the utility type and exact amount from a bill without a database.

metadata.ts
typescript
import { getPlateInfo, getBillInfo } from 'zod-ir';

const plate = getPlateInfo('12ب345-11');
console.log(plate.province);
console.log(plate.city);

const bill = getBillInfo('4172403661141', '10141604');
if (bill.isValid) {
  console.log(bill.type.label);
  console.log(bill.amount);
}