pakdatakit 2.7.0
pakdatakit: ^2.7.0 copied to clipboard
Pakistani data utilities for Dart and Flutter: validate CNIC, mobile, IBAN, NTN/STRN, passport and vehicle numbers; Raast QR codes, banks, postal codes, holidays and more.
Changelog #
2.7.0 #
Minor release: new features and one accuracy fix behind an option. Every port gives the same results on the shared test vectors (35,000+, about 1,800 new).
Added #
- Salary tax surcharge.
calculateSalaryTax()andcalculateMonthlySalaryTax()takeincludeSurchargeand returnsurchargeandtotal;getSalaryTaxSlabs()gives each year'sSalaryTaxSurcharge(nullbefore 2025). The section 4AB surcharge is a percentage of the whole tax once taxable income exceeds Rs 10 million: 10% in tax year 2025, 9% for salaried individuals in 2026, and none in 2027 or before 2025. The option is off by default in 2.x, so existing results don't change; it will be on by default in 3.0. - Service numbers as landlines.
validateLandline(phone, services: true)also accepts UAN, toll-free and premium-rate numbers. - CNICs in free text.
findCNICs(text)returnsCNICMatchobjects (raw,digits,formatted,start,end; offsets in UTF-16 code units);maskCNICs(text, mask: 'X')returnsMaskedText. Pattern matches: other 13-digit numbers starting with 1-8 also match; CNIC validation stays strict. - Phonetic keys for Roman Urdu names:
romanUrduKey(text)(without NFKD in Dart, accents are folded with a table generated from Node.js:scripts/generate-latin-fold-dart.mjs), so thatMubeenandMobeen, orRehmanandRahman, match. - Raast:
RaastQrValidation.kind(RaastQrKind?) and the warningRaastQrWarning.noIban.
Changed #
0122numbers are no longer recognised: they are seen in use, but no PTA document lists them.analyzeNumber()now returnsnullfor them;NumberType.personalis deprecated, never returned, and will be removed in 3.0.- Toll-free numbers follow PTA's numbering plan:
0800and five digits; the 8-digit form is no longer accepted. - A merchant Raast QR without an IBAN is valid with the warning
no-iban; a person-to-person QR without an IBAN is still an error.
2.6.0 #
Minor release: one new feature. Every port gives the same results on the shared test vectors (812 new ones).
Added #
parseAmount()andformatAmountInput()and theParsedAmountclass.parseAmountreads a rupee amount as people type it in Pakistan and returns{ value, raw }in rupees, rounded half-up to the paisa, ornull. It accepts150,000and1,50,000grouping with decimals, Urdu and Arabic-Indic digits,Rs/Rs./PKR/₨and a trailing/-, and the shorthandk,thousand,hazar,ہزار,lakh,lac,لاکھ,crore,crandکروڑ(also1.5 lakh,2.25cr). It rejects negatives, ranges, more than one number, leftover letters, ambiguous grouping and amounts over Rs. 50 trillion. The arithmetic is done on the digits, so1.005is 1.01 in every language.formatAmountInputwrites the amount back ("Rs. 150,000") for showing next to a field. It never throws.
2.5.1 #
Patch release: documentation, packaging and dependency updates. No API, behaviour or data changes; every port still gives the same results on the shared test vectors.
Changed #
- The README is rewritten for what PakDataKit is now: one library in TypeScript, Python, Dart/Flutter, .NET and PHP/Laravel with React, Vue and Angular helpers, with a table of every published package, an overview of the modules by area and a quick start for each language. The old roadmap is removed. The Dart, .NET and PHP READMEs now say 32,000+ shared test vectors.
- The Python source distribution (sdist) no longer includes
tests/: the tests needdata/andtest-vectors/from the repository, so they could not run from the sdist. - Release workflows only start on their own tags (
v1.2.3no longer also matchesvue-v1.2.3), and a version that is already on its registry is skipped with a notice instead of failing. - The .NET release keeps the attested
.nupkgfiles and attaches them to the GitHub release, since nuget.org re-signs packages and its copies cannot be checked against the build attestation. - Development dependencies updated (tsup 9, jsdom 31, Vitest 5.1, ESLint 10.15, Prettier 3.10, xunit 2.9.3, Microsoft.NET.Test.Sdk 18, and actions/attest-build-provenance 4).
2.5.0 #
Includes everything prepared for 2.4.0, which was never published on its own: the 2.4.0 changes are listed here with the 2.5.0 ones.
Added #
calculateSalaryTax()andcalculateMonthlySalaryTax(): income tax on a salaried individual's taxable income from the salaried rate table of the Income Tax Ordinance 2001 for tax years 2020 to 2027, as aSalaryTax(tax,monthly,effectiveRate,slab,taxYear), rounded half up to the paisa, exactly on every platform.getSalaryTaxSlabs()returns a year's table (SalaryTaxYear,SalaryTaxSlab) with its law and FBR source,getSalaryTaxYears()the years covered andgetTaxYear()the tax year of a date. Also aspackage:pakdatakit/incometax.dart.slugify(): URL slugs that keep Urdu letters (SlugScriptlimits the script);compareUrdu(): Urdu alphabetical order from the CLDR collation, forList.sort, without ICU;isRTL()andwrapBidi()(BidiDirection): right-to-left detection and Unicode directional isolates.scoreAddress(): scores how complete a delivery address is (0-100), with themissingAddressParts and theparseAddressresult, and warns when a known post office code is in a different province from the city.phoneRiskSignals():PhoneRiskFlags for a phone number a courier cannot reach or that looks made up (landline, service number, repeated or sequential digits, placeholder numbers). AlsoaddressWeights, and aspackage:pakdatakit/quality.dart.getSalesTaxRate(): the standard sales tax rate on goods (FBR) or on services in a province or Islamabad Capital Territory on a date, from 1 July 2019, with the authority, law and source (SalesTaxRate,SalesTaxKind).calculateSalesTax()adds tax at a rate or a looked-up rate, or splits it out withinclusive: true;splitInclusive()splits a tax-inclusive amount. Both returnSalesTaxAmounts, rounded half up to the paisa, exactly on every platform. Also aspackage:pakdatakit/salestax.dart.parseElectricityRef()andvalidateElectricityRef(): a DISCO (WAPDA) 14-digit reference number with optional U/R, a DISCO customer ID (10 or 11 digits) or a 13-digit K-Electric account number, as anElectricityRef(typeas anElectricityRefType,digits,formatted,urbanRural,disco).validateGasConsumerNumber()checks an SNGPL (11-digit) or SSGC (10-digit) consumer number (GasCompany). Format checks only; no utility publishes a check digit. Also aspackage:pakdatakit/bills.dart.mapCourierStatus(): maps a courier's own status (name, numeric ID or code) to one vocabulary,CourierStatus, from PostEx's merchant API guide and Leopards' "Returned to Shipper" (Couriernames the couriers).normalizeCityForCourier()maps short forms (LHR,Khi,Pindi), the old name Lyallpur, a trailing "city" and Urdu script to the city list. No API is called. Also aspackage:pakdatakit/courier.dart.buildFbrInvoice()andvalidateFbrInvoice(): FBR Digital Invoicing, for the invoice JSON (Map<String, Object?>, typedefFbrInvoice) posted to PRAL's DI API (specification 1.12,fbrDiSpecVersion). The builder works out each line's sales tax (expectedSalesTax():N%orRs.Nper unit, withcalculateSalesTax), fills FBR's defaults and adds up the columns (FbrInvoiceBuild,FbrInvoiceTotals); the validator returns every problem it can find offline with FBR's error code (FbrInvoiceValidation,FbrInvoiceError), optionally rejecting future dates withtoday:. AlsoFbrInvoiceTypeandFbrRegistrationType. No HTTP client and no token handling. Also aspackage:pakdatakit/fbr_invoice.dart.
Changed #
- Package metadata: the description, keywords and homepage now follow the same
style in every registry, and CI checks that the version, repository URL,
licence and author agree across ports (
npm run check:metadata). dataVersionis now2026-11-18(new dataset: sales tax rates).
2.3.0 #
Breaking for exhaustive switches #
BankTypehas a new value,BankType.publicSector('public-sector'; see Data depth below). Dart 3 checksswitchstatements and expressions over an enum for exhaustiveness, so aswitchoverBankTypewithout a default (_) case stops compiling until it handles the new value. Nothing else changes at runtime for such code, but National Bank of Pakistan, Sindh Bank, The Bank of Khyber and The Bank of Punjab now reportBankType.publicSectorinstead ofBankType.commercial.
Added #
validatePassport(): format check for Pakistani passport numbers (two letters, seven digits). DGIP does not publish the format, so this checks the common shape only. Also aspackage:pakdatakit/passport.dart.validateVehiclePlate()andparseVehiclePlate(): series, number and optional year of a vehicle registration number (1–4 letters, 1–4 digits). Provinces use different formats, so this checks the shape they share. Also aspackage:pakdatakit/vehicle.dart.getPostOffice()andsearchPostOffices()(also inpackage:pakdatakit/postal.dart): every delivery post office in Pakistan Post's directory (about 2,560), asPostOfficevalues (code,office,town,district,province), including offices in towns and villages thatgetCityByPostalCodedoes not cover. The directory is in its own source file and only these two functions reference it, so release builds that do not call them leave it out.- All of these are checked against the shared test vectors. See DATA.md in the repository for sources and limits.
Data (November 2026 audit, see AUDIT.md and DATA.md in the repository):
banks ZTBL (Zarai Taraqiati Bank Limited) and SMFB (Sindh Microfinance
Bank) added; TMFB/TAMW renamed "Easypaisa Bank Limited" and JCMA/WMBL
"Mobilink Microfinance Bank (JazzCash)"; eight postal codes corrected from
Pakistan Post's directory (Gilgit, Dera Ismail Khan, Tank, Badin, Thatta,
Sujawal, Matiari, Taxila) and Wah Cantonment 47040 added; holiday source
links for 2024 to 2026 now point to official notifications.
Data depth:
getDivisions(),getDivisionOfDistrict(),getTehsils()andgetTehsilDistrict(): division and tehsil lookups from the 2023 census (30 divisions, 591 tehsils). Each tehsil is recorded under its census district, so districts created since the census may list few or no tehsils and have no division.- Postal codes now hold every office in Pakistan Post's directory that
belongs to a listed city: 457 codes, up from 110.
getCityByPostalCodestill returns a listed city ornull, so a village office's code returnsnull(usegetPostOfficefor those). Compared with 2.2.1 it gives a different answer for eight codes:47040is Wah Cantonment (was Taxila), and15700,29120,29430,70100,72220,73020and73220, which were given as the main code of a city but belong to a village office nearby, now returnnull. - 41 more landline area codes.
BankType.publicSector('public-sector') for public sector commercial banks;BankType.commercialnow means private commercial banks.- SME Bank (
SMES) is reported as inactive (active: false).
dataVersion is now 2026-11-17.
2.2.1 #
The district split from Swat in January 2026 is now named Bar Swat, as in
the Khyber Pakhtunkhwa Board of Revenue notification of 27 January 2026,
instead of "Upper Swat". "Upper Swat" still resolves in getDistrictProvince to Khyber Pakhtunkhwa.
dataVersion is now 2026-11-07.
2.2.0 #
Initial Dart release, matching version 2.2.0 of the
pakdatakit npm package (datasets
checked 2026-10-14).
- Every function of the npm package, with the same names: CNIC, mobile numbers and networks, WhatsApp links, IBAN and banks, postal codes, cities and districts, address parsing, text and Roman Urdu, Hijri dates, public holidays, PKR formatting, amounts in words, NTN/STRN, landlines and other numbers, Raast QR codes, and form-input helpers.
- Pure Dart with no dependencies; the datasets are embedded, so it works on every platform, including Flutter web.
- Per-module libraries mirroring the npm entry points
(
package:pakdatakit/cnic.dart, …). - Tested against the 12,080 shared test vectors generated from the TypeScript library, on the Dart VM and compiled to JavaScript.