pakdatakit 2.1.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DATA.md +104 -0
- package/README.md +93 -6
- package/dist/address.cjs +4 -4
- package/dist/address.js +2 -2
- package/dist/{chunk-PHHKIMO2.cjs → chunk-33FXHM2E.cjs} +5 -5
- package/dist/chunk-3IARSCO6.cjs +317 -0
- package/dist/{chunk-BSS4Z7NI.cjs → chunk-3ZA265SK.cjs} +2 -2
- package/dist/{chunk-43ULDYUP.cjs → chunk-4VSGCQ6K.cjs} +107 -11
- package/dist/{chunk-Y6BUGLXU.js → chunk-6IPPANNX.js} +4 -1
- package/dist/{chunk-L45UXUWX.js → chunk-AZV45DMG.js} +1 -1
- package/dist/{chunk-QQQKISXT.js → chunk-BR4QLZPX.js} +11 -2
- package/dist/{chunk-AUATLZA5.cjs → chunk-CLL6VDPO.cjs} +4 -4
- package/dist/{chunk-P4CGOJEM.js → chunk-EMH4IP2U.js} +1 -1
- package/dist/{chunk-JNP27XW2.cjs → chunk-GJENL6VK.cjs} +6 -6
- package/dist/{chunk-APXP7OK7.cjs → chunk-HIZQBWNW.cjs} +11 -2
- package/dist/{chunk-YS7MOLK2.cjs → chunk-HTERSQGF.cjs} +3 -3
- package/dist/{chunk-E7GAK72W.js → chunk-HUQY2WR5.js} +3 -3
- package/dist/{chunk-L2BDDM2W.js → chunk-I664KOWP.js} +1 -1
- package/dist/{chunk-K6CZFCX6.js → chunk-J272OMDL.js} +51 -6
- package/dist/{chunk-KQKW2ZEK.cjs → chunk-NAJGGUAM.cjs} +2 -2
- package/dist/{chunk-YLWZGSFY.cjs → chunk-NTD4JLDW.cjs} +4 -0
- package/dist/{chunk-44YRK7WO.js → chunk-NZQ47NWD.js} +105 -10
- package/dist/{chunk-432ZYMYV.js → chunk-PLDVGOKZ.js} +2 -2
- package/dist/{chunk-T3E4B5MJ.js → chunk-RXNYY5K5.js} +1 -1
- package/dist/{chunk-3COX5FSL.cjs → chunk-SBS2GHM3.cjs} +51 -6
- package/dist/chunk-TTARJWGT.js +82 -0
- package/dist/chunk-U7MWHXMF.cjs +89 -0
- package/dist/chunk-YPPKY5XZ.js +312 -0
- package/dist/cli.js +1 -1
- package/dist/geo.cjs +6 -6
- package/dist/geo.js +1 -1
- package/dist/holidays.d.cts +2 -1
- package/dist/holidays.d.ts +2 -1
- package/dist/iban.cjs +11 -3
- package/dist/iban.d.cts +45 -1
- package/dist/iban.d.ts +45 -1
- package/dist/iban.js +1 -1
- package/dist/index.cjs +76 -37
- package/dist/index.d.cts +11 -2
- package/dist/index.d.ts +11 -2
- package/dist/index.js +16 -10
- package/dist/input.cjs +34 -0
- package/dist/input.d.cts +67 -0
- package/dist/input.d.ts +67 -0
- package/dist/input.js +5 -0
- package/dist/networks.cjs +3 -3
- package/dist/networks.js +2 -2
- package/dist/numbers.cjs +6 -6
- package/dist/numbers.js +2 -2
- package/dist/phone.cjs +8 -8
- package/dist/phone.js +3 -3
- package/dist/raast.cjs +9 -5
- package/dist/raast.d.cts +68 -5
- package/dist/raast.d.ts +68 -5
- package/dist/raast.js +2 -2
- package/dist/valibot.cjs +7 -7
- package/dist/valibot.js +6 -6
- package/dist/whatsapp.cjs +3 -3
- package/dist/whatsapp.js +2 -2
- package/dist/words.cjs +3 -3
- package/dist/words.js +1 -1
- package/dist/yup.cjs +7 -7
- package/dist/yup.js +6 -6
- package/dist/zod.cjs +7 -7
- package/dist/zod.js +6 -6
- package/package.json +16 -3
- package/dist/chunk-4EUKCSLW.js +0 -221
- package/dist/chunk-E47SNBWQ.cjs +0 -224
package/DATA.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Data sources
|
|
2
|
+
|
|
3
|
+
PakDataKit's datasets live in `data/` and are generated by
|
|
4
|
+
`scripts/generate-data.mjs` (except `networks.json`, `area-codes.json` and
|
|
5
|
+
`holidays.json`, which are edited directly). The exported `dataVersion` is the
|
|
6
|
+
date the data was last checked.
|
|
7
|
+
|
|
8
|
+
**Data version: 2026-10-14**
|
|
9
|
+
|
|
10
|
+
Official bodies (PTA, NADRA, SBP, Pakistan Post) publish few machine-readable
|
|
11
|
+
lists, so some entries rest on secondary sources. Each section says how sure we
|
|
12
|
+
are. To correct an entry, open an issue or pull request with a source.
|
|
13
|
+
|
|
14
|
+
## Banks (`banks.json`): IBAN bank codes
|
|
15
|
+
|
|
16
|
+
SBP does not publish a list of IBAN bank codes, and IBAN codes do not always
|
|
17
|
+
match SWIFT BIC prefixes (e.g. Silkbank is `SAUD`). Codes are therefore checked
|
|
18
|
+
against real IBANs.
|
|
19
|
+
|
|
20
|
+
- **Confirmed from real IBANs:** most commercial and microfinance banks, from
|
|
21
|
+
SBP's account lists for the 2022 flood relief fund and the 2023 Türkiye–Syria
|
|
22
|
+
earthquake relief fund, plus charity donation pages (TCF, Alkhidmat). This
|
|
23
|
+
includes `KHBL` (Khushhali), `JCMA` and `WMBL` (Mobilink Bank), `TMFB`
|
|
24
|
+
(easypaisa), `FMFB` (HBL Microfinance), `FINC` (ABHI), `UMBL`, `NRSP`,
|
|
25
|
+
`APNA`, `BKCH`, `ICBK`, `CITI`, `SUMB` (Bank Makramah), `SAMB`, `SMES` and
|
|
26
|
+
`SAUD`.
|
|
27
|
+
- **Confirmed from published IBANs on smaller sites:** `SADA` (SadaPay), `NAYA`
|
|
28
|
+
(NayaPay).
|
|
29
|
+
- **Confirmed from real account IBANs shared by a maintainer:** `RQMI` (Raqami
|
|
30
|
+
Islamic Digital Bank) and `MSHQ` (Mashreq Bank Pakistan), both digital banks.
|
|
31
|
+
- **Likely, not confirmed by a real IBAN:** `DEUT` (Deutsche Bank), `SBPP`
|
|
32
|
+
(State Bank of Pakistan).
|
|
33
|
+
- **Not included, because no code could be confirmed:** HugoBank (in pilot,
|
|
34
|
+
not yet issuing IBANs), KT Bank (reportedly renamed Buraq Bank), LOLC Microfinance
|
|
35
|
+
(formerly Pak Oman), Zarai Taraqiati Bank and Bank of AJK.
|
|
36
|
+
- **Merged or renamed** banks keep their code with the current name, e.g.
|
|
37
|
+
`SAUD` → "Silkbank Limited (merged into United Bank Limited)".
|
|
38
|
+
|
|
39
|
+
## Mobile networks (`networks.json`)
|
|
40
|
+
|
|
41
|
+
`03XX` prefixes and the operator each was originally allocated to. PTA does not
|
|
42
|
+
publish an allocation table; prefixes are cross-checked with Google
|
|
43
|
+
libphonenumber and operator announcements.
|
|
44
|
+
|
|
45
|
+
- `0329` (Jazz) and `0355` (SCO) included.
|
|
46
|
+
- `0370`–`0371` (Zong) included; `0372`–`0379` are **not**, as no allocation or
|
|
47
|
+
use was found.
|
|
48
|
+
- `0364` (Instaphone, licence cancelled in 2008) is not included.
|
|
49
|
+
- `034x` is labelled Telenor, the original allocation; Telenor Pakistan merged
|
|
50
|
+
into PTML (Ufone) in 2026. With number portability, the current operator can
|
|
51
|
+
differ for any prefix.
|
|
52
|
+
|
|
53
|
+
## Landline area codes (`area-codes.json`)
|
|
54
|
+
|
|
55
|
+
From PTCL's national dialling-code list, cross-checked with libphonenumber's
|
|
56
|
+
geocoding data. Muzaffarabad, Mirpur and Gilgit codes are left out because only
|
|
57
|
+
third-party sources give them. Number patterns in `numbers.ts` come from
|
|
58
|
+
libphonenumber's PK metadata (v9.0.41).
|
|
59
|
+
|
|
60
|
+
## Districts (`districts.json`)
|
|
61
|
+
|
|
62
|
+
177 districts as of October 2026: Punjab 41, Sindh 30, Khyber Pakhtunkhwa 40,
|
|
63
|
+
Balochistan 41, Gilgit-Baltistan 14, Azad Jammu and Kashmir 10, Islamabad 1.
|
|
64
|
+
|
|
65
|
+
- **Khyber Pakhtunkhwa** (APP, January 2026: "increased to 40"): Lower and Upper
|
|
66
|
+
South Waziristan (2022), Central Dir and Allai (January 2023), Paharpur
|
|
67
|
+
(November 2025), Upper Swat (January 2026).
|
|
68
|
+
- **Balochistan** (Revenue Department notification, 8 July 2026; Dawn,
|
|
69
|
+
ProPakistani): Quetta split into Quetta East and Quetta West; Dera Bugti
|
|
70
|
+
became South Dera Bugti and Upper Dera Bugti became North Dera Bugti; new
|
|
71
|
+
Barshore, Tump and Wadh districts; Hub and Usta Muhammad (2022). Taftan is not
|
|
72
|
+
included: no notification was found and the official count of 41 is reached
|
|
73
|
+
without it.
|
|
74
|
+
- **Punjab:** Taunsa, Kot Addu, Murree, Wazirabad and Talagang (2022). A 2026
|
|
75
|
+
notification of four more districts was confirmed fake.
|
|
76
|
+
- **Sindh:** proposed Karachi district renames (2024) were not found notified,
|
|
77
|
+
so current names are kept.
|
|
78
|
+
- Former names (Quetta, Dera Bugti, Upper Dera Bugti, South Waziristan) still
|
|
79
|
+
resolve in `getDistrictProvince`.
|
|
80
|
+
|
|
81
|
+
## Cities (`cities.json`)
|
|
82
|
+
|
|
83
|
+
District headquarters and major towns, plus every city that has a postal code
|
|
84
|
+
in `postal-codes.json`, each mapped to its province.
|
|
85
|
+
|
|
86
|
+
## Postal codes (`postal-codes.json`)
|
|
87
|
+
|
|
88
|
+
Principal post office codes for major cities (109 entries). Pakistan Post has no
|
|
89
|
+
downloadable dataset, only a lookup tool, so coverage is limited.
|
|
90
|
+
|
|
91
|
+
## Public holidays (`holidays.json`)
|
|
92
|
+
|
|
93
|
+
Eid ul Fitr, Eid ul Adha, Ashura and Eid Milad un Nabi dates actually observed
|
|
94
|
+
in 2020–2026, from Cabinet Division notifications and SBP circulars; each entry
|
|
95
|
+
has a `source` URL. Later years are estimated from the tabular Hijri calendar
|
|
96
|
+
and marked `estimated: true`. Fixed-date holidays follow the years they applied
|
|
97
|
+
in (e.g. Iqbal Day restored in 2022, Youm-e-Takbeer from 2024).
|
|
98
|
+
|
|
99
|
+
## CNIC
|
|
100
|
+
|
|
101
|
+
First digit = province of registration, per FBR's tax-ID description filed with
|
|
102
|
+
the OECD (1 Khyber Pakhtunkhwa, 2 former FATA, 3 Punjab, 4 Sindh, 5
|
|
103
|
+
Balochistan, 6 Islamabad, 7 Gilgit-Baltistan). `8` for Azad Jammu and Kashmir
|
|
104
|
+
comes from secondary sources only. Last digit odd = male, even = female.
|
package/README.md
CHANGED
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
<a href="https://pakdatakit-playground.vercel.app/">
|
|
25
25
|
<img src="https://img.shields.io/badge/playground-try%20it%20live-brightgreen" alt="Playground">
|
|
26
26
|
</a>
|
|
27
|
+
<a href="https://chmuzamil.github.io/pakdatakit/">
|
|
28
|
+
<img src="https://img.shields.io/badge/docs-API%20reference-blue" alt="API docs">
|
|
29
|
+
</a>
|
|
27
30
|
</p>
|
|
28
31
|
|
|
29
32
|
---
|
|
@@ -38,6 +41,26 @@ Validate CNICs, analyze phone numbers, detect networks, build WhatsApp links, ch
|
|
|
38
41
|
|
|
39
42
|
---
|
|
40
43
|
|
|
44
|
+
## 📦 Packages
|
|
45
|
+
|
|
46
|
+
| Package | Install | For |
|
|
47
|
+
| --------------------------------------------------------------------------------- | ------------------------------ | -------------------------------------------------------------- |
|
|
48
|
+
| [`pakdatakit`](https://www.npmjs.com/package/pakdatakit) | `npm install pakdatakit` | JavaScript and TypeScript (Node, browsers, Bun, Deno) |
|
|
49
|
+
| [`pakdatakit` (Python)](https://github.com/chmuzamil/pakdatakit/tree/main/python) | `pip install pakdatakit` | Python 3.9+, same functions in snake_case, same data |
|
|
50
|
+
| [`pakdatakit-react`](https://github.com/chmuzamil/pakdatakit/tree/main/react) | `npm install pakdatakit-react` | React inputs that format as you type, and a Raast QR component |
|
|
51
|
+
|
|
52
|
+
The Python package is checked against the TypeScript library with over 12,000 shared test cases, so both give the same results.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## 📚 Documentation
|
|
57
|
+
|
|
58
|
+
- **[API reference](https://chmuzamil.github.io/pakdatakit/)**: every function, option and return type
|
|
59
|
+
- **[llms.txt](https://chmuzamil.github.io/pakdatakit/llms.txt)** and **[llms-full.txt](https://chmuzamil.github.io/pakdatakit/llms-full.txt)**: the library in a form AI coding assistants can read
|
|
60
|
+
- **[DATA.md](./DATA.md)**: where every dataset comes from
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
41
64
|
## Why PakDataKit?
|
|
42
65
|
|
|
43
66
|
Every Pakistani application eventually needs to solve the same problems:
|
|
@@ -78,6 +101,7 @@ PakDataKit provides a single, typed, reusable solution so you can focus on build
|
|
|
78
101
|
- ✅ Lakh / Crore Formatting
|
|
79
102
|
- ✅ Amounts in Words (English & Urdu, cheque style)
|
|
80
103
|
- ✅ Zod, Valibot & Yup Form Validation
|
|
104
|
+
- ✅ As-You-Type Formatting for CNIC, Phone & IBAN
|
|
81
105
|
- ✅ NTN & STRN Validation
|
|
82
106
|
- ✅ Landline, UAN (111), Toll-Free (0800) & Premium (0900) Numbers
|
|
83
107
|
- ✅ Raast QR Codes (SBP standard)
|
|
@@ -112,7 +136,7 @@ import { validateCNIC } from 'pakdatakit/cnic';
|
|
|
112
136
|
const { analyzePhone } = require('pakdatakit/phone');
|
|
113
137
|
```
|
|
114
138
|
|
|
115
|
-
Subpaths: `address`, `cnic`, `format`, `geo`, `hijri`, `holidays`, `iban`, `networks`, `numbers`, `phone`, `postal`, `raast`, `tax`, `text`, `whatsapp`, `words`, plus the form adapters `zod`, `valibot` and `yup`.
|
|
139
|
+
Subpaths: `address`, `cnic`, `format`, `geo`, `hijri`, `holidays`, `iban`, `input`, `networks`, `numbers`, `phone`, `postal`, `raast`, `tax`, `text`, `whatsapp`, `words`, plus the form adapters `zod`, `valibot` and `yup`.
|
|
116
140
|
|
|
117
141
|
---
|
|
118
142
|
|
|
@@ -369,7 +393,7 @@ getBankFromIBAN('invalid');
|
|
|
369
393
|
// null
|
|
370
394
|
```
|
|
371
395
|
|
|
372
|
-
Supported bank codes include HABB, MEZN, SCBL, UNIL, BAHL, NBPA, MUCB, JSBL, SADA (SadaPay), and
|
|
396
|
+
Supported bank codes include HABB, MEZN, SCBL, UNIL, BAHL, NBPA, MUCB, JSBL, SADA (SadaPay), NAYA (NayaPay), RQMI (Raqami), MSHQ (Mashreq), and 48 total entries in the dataset, checked against real IBANs (see [DATA.md](./DATA.md)). Merged or renamed banks are labelled with their current name, e.g. `SAUD` → "Silkbank Limited (merged into United Bank Limited)".
|
|
373
397
|
|
|
374
398
|
---
|
|
375
399
|
|
|
@@ -521,7 +545,7 @@ searchCities('kar');
|
|
|
521
545
|
|
|
522
546
|
### getDistrictProvince() / searchDistricts()
|
|
523
547
|
|
|
524
|
-
District-level geography lookup across
|
|
548
|
+
District-level geography lookup across 177 districts, including the 2026 Balochistan and Khyber Pakhtunkhwa changes. Former names such as Quetta and South Waziristan still resolve.
|
|
525
549
|
|
|
526
550
|
```ts
|
|
527
551
|
getDistrictProvince('Lahore'); // "Punjab"
|
|
@@ -690,14 +714,26 @@ FBR does not publish its check-digit algorithms, so these check the format only.
|
|
|
690
714
|
Builds and reads payment QR codes following the State Bank of Pakistan's QR standard (Circular Letter No. 1 of 2022). Turn the returned string into an image with any QR library.
|
|
691
715
|
|
|
692
716
|
```ts
|
|
693
|
-
// Person-to-person: anyone can pay this IBAN through Raast
|
|
717
|
+
// Person-to-person: anyone can pay this IBAN through Raast; the payer enters the amount
|
|
718
|
+
createRaastP2PQr({ iban: 'PK36SCBL0000001123456702' });
|
|
719
|
+
|
|
720
|
+
// With a fixed amount: banking apps require an expiry
|
|
694
721
|
const payload = createRaastP2PQr({
|
|
695
722
|
iban: 'PK36SCBL0000001123456702',
|
|
696
723
|
amount: 1500,
|
|
724
|
+
expiresAt: new Date(2026, 10, 13, 23, 59),
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
// …or give how long it works: '30m', '12h', '7d' or milliseconds
|
|
728
|
+
createRaastP2PQr({
|
|
729
|
+
iban: 'PK36SCBL0000001123456702',
|
|
730
|
+
amount: 1500,
|
|
731
|
+
expiresIn: '1d',
|
|
697
732
|
});
|
|
698
733
|
|
|
699
734
|
parseRaastQr(payload);
|
|
700
|
-
// { kind: 'p2p', dynamic: true, crcValid: true, iban: 'PK36SCBL0000001123456702',
|
|
735
|
+
// { kind: 'p2p', dynamic: true, crcValid: true, iban: 'PK36SCBL0000001123456702',
|
|
736
|
+
// amount: 1500, expiresAt: '2026-11-13T23:59', ... }
|
|
701
737
|
|
|
702
738
|
// Merchant QR (EMVCo), with Pakistan-specific bill due dates
|
|
703
739
|
createMerchantQr({
|
|
@@ -716,10 +752,29 @@ createMerchantQr({
|
|
|
716
752
|
});
|
|
717
753
|
```
|
|
718
754
|
|
|
719
|
-
Person-to-person QR codes use the same layout as QR codes from banking apps (Faysal Bank
|
|
755
|
+
Person-to-person QR codes use the same layout as QR codes from banking apps (Faysal Bank and easypaisa without an amount; JazzCash and Mashreq with one), and scan in the Easypaisa and JazzCash apps. This is handy for accounts whose app cannot generate a receiving QR, such as SadaPay. A QR with an amount must have `expiresAt`: apps reject amount QRs without an expiry, and ignore an amount in a QR that has none.
|
|
720
756
|
|
|
721
757
|
SBP reserves merchant-account tags 28–30 for Raast but has shared the layout of the fields inside them only with banks, so `createMerchantQr` takes those sub-fields from you. `parseRaastQr` checks the CRC and finds the IBAN in either kind of QR.
|
|
722
758
|
|
|
759
|
+
### validateRaastQr()
|
|
760
|
+
|
|
761
|
+
Checks a scanned QR before anyone pays, for example to warn about a QR sticker that was replaced or edited.
|
|
762
|
+
|
|
763
|
+
```ts
|
|
764
|
+
validateRaastQr(scannedText);
|
|
765
|
+
// { valid: false, errors: ['expired'], warnings: [], qr: { iban: 'PK36…', amount: 1500, … } }
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
| Errors | Meaning |
|
|
769
|
+
| -------------------------- | ------------------------------------------------------------ |
|
|
770
|
+
| `not-a-raast-qr` | Not a Pakistani payment QR |
|
|
771
|
+
| `bad-checksum` | The QR was damaged or its contents were edited |
|
|
772
|
+
| `no-iban` / `invalid-iban` | No IBAN, or one that fails its checksum |
|
|
773
|
+
| `expired` | A QR with an amount is past its expiry |
|
|
774
|
+
| `missing-expiry` | A QR with an amount has no expiry, so banking apps reject it |
|
|
775
|
+
|
|
776
|
+
Warnings (payment still works): `amount-ignored` when a static QR carries an amount that apps ignore, and `expires-soon` when it expires within an hour (`expiresSoonMs` changes this). Pass `now` to check against another time.
|
|
777
|
+
|
|
723
778
|
---
|
|
724
779
|
|
|
725
780
|
## Public Holidays
|
|
@@ -775,6 +830,38 @@ const CheckoutForm = object({ cnic: pk.cnic().required(), phone: pk.phone() });
|
|
|
775
830
|
|
|
776
831
|
Available schemas: `pk.cnic()`, `pk.phone()`, `pk.iban()`, `pk.ntn()`, `pk.strn()` and `pk.landline()`. Every factory accepts `{ message }` to replace the default error. The Yup schemas let empty values pass so `.required()` decides whether a field is mandatory.
|
|
777
832
|
|
|
833
|
+
### As-you-type helpers
|
|
834
|
+
|
|
835
|
+
Format a field while the user types, and tell a half-typed value apart from a wrong one, so you don't show an error before they've finished.
|
|
836
|
+
|
|
837
|
+
```ts
|
|
838
|
+
import { formatCNICInput, checkCNICInput } from 'pakdatakit/input';
|
|
839
|
+
|
|
840
|
+
formatCNICInput('352021234'); // "35202-1234"
|
|
841
|
+
checkCNICInput('35202-1234'); // "incomplete" — keep typing
|
|
842
|
+
checkCNICInput('05202'); // "invalid" — no CNIC starts with 0
|
|
843
|
+
checkCNICInput('35202-1234567-1'); // "valid"
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
| Field | Formatter | Checker |
|
|
847
|
+
| ------ | -------------------------------------------------------- | ---------------------------------------------------------------------------- |
|
|
848
|
+
| CNIC | `formatCNICInput` → `35202-1234567-1` | `checkCNICInput` |
|
|
849
|
+
| Mobile | `formatPhoneInput` → `0300-1234567` or `+92 300 1234567` | `checkPhoneInput` (flags an unallocated `03XX` prefix as soon as it's typed) |
|
|
850
|
+
| IBAN | `formatIBANInput` → `PK36 SCBL 0000 0011 2345 6702` | `checkIBANInput` |
|
|
851
|
+
|
|
852
|
+
Checkers return `'empty'`, `'incomplete'`, `'valid'` or `'invalid'`. In React, for example:
|
|
853
|
+
|
|
854
|
+
```tsx
|
|
855
|
+
const [cnic, setCnic] = useState('');
|
|
856
|
+
const state = checkCNICInput(cnic);
|
|
857
|
+
|
|
858
|
+
<input
|
|
859
|
+
value={cnic}
|
|
860
|
+
onChange={(e) => setCnic(formatCNICInput(e.target.value))}
|
|
861
|
+
aria-invalid={state === 'invalid'}
|
|
862
|
+
/>;
|
|
863
|
+
```
|
|
864
|
+
|
|
778
865
|
---
|
|
779
866
|
|
|
780
867
|
# Real-World Example
|
package/dist/address.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkCLL6VDPO_cjs = require('./chunk-CLL6VDPO.cjs');
|
|
4
4
|
require('./chunk-4VVFS6FN.cjs');
|
|
5
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-SBS2GHM3.cjs');
|
|
6
6
|
require('./chunk-VPBMIYO2.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "formatAddress", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkCLL6VDPO_cjs.formatAddress; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "parseAddress", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunkCLL6VDPO_cjs.parseAddress; }
|
|
17
17
|
});
|
package/dist/address.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkHTERSQGF_cjs = require('./chunk-HTERSQGF.cjs');
|
|
4
|
+
var chunkNTD4JLDW_cjs = require('./chunk-NTD4JLDW.cjs');
|
|
5
5
|
|
|
6
6
|
// src/phone.ts
|
|
7
7
|
function validatePhone(phone) {
|
|
8
|
-
return
|
|
8
|
+
return chunkNTD4JLDW_cjs.normalizePhoneDigits(phone) !== null;
|
|
9
9
|
}
|
|
10
10
|
function formatPhone(phone) {
|
|
11
|
-
const digits =
|
|
11
|
+
const digits = chunkNTD4JLDW_cjs.normalizePhoneDigits(phone);
|
|
12
12
|
if (digits === null) {
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
@@ -26,7 +26,7 @@ function analyzePhone(phone) {
|
|
|
26
26
|
return {
|
|
27
27
|
valid: true,
|
|
28
28
|
formatted,
|
|
29
|
-
network:
|
|
29
|
+
network: chunkHTERSQGF_cjs.getNetwork(phone)
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
4
|
+
|
|
5
|
+
// data/banks.json
|
|
6
|
+
var banks_default = [
|
|
7
|
+
{
|
|
8
|
+
code: "ABPA",
|
|
9
|
+
name: "Allied Bank Limited",
|
|
10
|
+
type: "commercial"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
code: "AIIN",
|
|
14
|
+
name: "Al Baraka Bank (Pakistan) Limited",
|
|
15
|
+
type: "islamic"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
code: "ALFH",
|
|
19
|
+
name: "Bank Alfalah Limited",
|
|
20
|
+
type: "commercial"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
code: "APNA",
|
|
24
|
+
name: "Apna Microfinance Bank",
|
|
25
|
+
type: "microfinance"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
code: "ASCM",
|
|
29
|
+
name: "Askari Bank Limited",
|
|
30
|
+
type: "commercial"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
code: "BAHL",
|
|
34
|
+
name: "Bank Al Habib Limited",
|
|
35
|
+
type: "commercial"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
code: "BKCH",
|
|
39
|
+
name: "Bank of China Limited",
|
|
40
|
+
type: "foreign"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
code: "BKIP",
|
|
44
|
+
name: "BankIslami Pakistan Limited",
|
|
45
|
+
type: "islamic"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
code: "BPUN",
|
|
49
|
+
name: "The Bank of Punjab",
|
|
50
|
+
type: "commercial"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
code: "CITI",
|
|
54
|
+
name: "Citibank N.A. Pakistan",
|
|
55
|
+
type: "foreign"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
code: "DEUT",
|
|
59
|
+
name: "Deutsche Bank AG",
|
|
60
|
+
type: "foreign"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
code: "DUIB",
|
|
64
|
+
name: "Dubai Islamic Bank Pakistan Limited",
|
|
65
|
+
type: "islamic"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
code: "FAYS",
|
|
69
|
+
name: "Faysal Bank Limited",
|
|
70
|
+
type: "islamic"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
code: "FINC",
|
|
74
|
+
name: "ABHI Microfinance Bank (formerly FINCA Microfinance Bank)",
|
|
75
|
+
type: "microfinance"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
code: "FMFB",
|
|
79
|
+
name: "HBL Microfinance Bank (formerly First MicroFinance Bank)",
|
|
80
|
+
type: "microfinance"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
code: "FWOM",
|
|
84
|
+
name: "First Women Bank Limited",
|
|
85
|
+
type: "commercial"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
code: "HABB",
|
|
89
|
+
name: "Habib Bank Limited",
|
|
90
|
+
type: "commercial"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
code: "ICBK",
|
|
94
|
+
name: "Industrial and Commercial Bank of China",
|
|
95
|
+
type: "foreign"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
code: "JCMA",
|
|
99
|
+
name: "Mobilink Bank (JazzCash)",
|
|
100
|
+
type: "microfinance"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
code: "JSBL",
|
|
104
|
+
name: "JS Bank Limited",
|
|
105
|
+
type: "commercial"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
code: "KHBL",
|
|
109
|
+
name: "Khushhali Microfinance Bank",
|
|
110
|
+
type: "microfinance"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
code: "KHYB",
|
|
114
|
+
name: "The Bank of Khyber",
|
|
115
|
+
type: "commercial"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
code: "MCBL",
|
|
119
|
+
name: "MCB Bank Limited",
|
|
120
|
+
type: "commercial",
|
|
121
|
+
aliasOf: "MUCB"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
code: "MCIB",
|
|
125
|
+
name: "MCB Islamic Bank Limited",
|
|
126
|
+
type: "islamic"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
code: "MEZN",
|
|
130
|
+
name: "Meezan Bank Limited",
|
|
131
|
+
type: "islamic"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
code: "MPBL",
|
|
135
|
+
name: "Habib Metropolitan Bank Limited",
|
|
136
|
+
type: "commercial"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
code: "MSHQ",
|
|
140
|
+
name: "Mashreq Bank Pakistan Limited",
|
|
141
|
+
type: "digital"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
code: "MUCB",
|
|
145
|
+
name: "MCB Bank Limited",
|
|
146
|
+
type: "commercial"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
code: "NAYA",
|
|
150
|
+
name: "NayaPay",
|
|
151
|
+
type: "emi"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
code: "NBPA",
|
|
155
|
+
name: "National Bank of Pakistan",
|
|
156
|
+
type: "commercial"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
code: "NBPB",
|
|
160
|
+
name: "National Bank of Pakistan",
|
|
161
|
+
type: "commercial",
|
|
162
|
+
aliasOf: "NBPA"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
code: "NIBP",
|
|
166
|
+
name: "NIB Bank Limited (merged into MCB Bank)",
|
|
167
|
+
type: "commercial",
|
|
168
|
+
mergedInto: "MUCB"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
code: "NRSP",
|
|
172
|
+
name: "NRSP Microfinance Bank",
|
|
173
|
+
type: "microfinance"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
code: "RQMI",
|
|
177
|
+
name: "Raqami Islamic Digital Bank Limited",
|
|
178
|
+
type: "digital"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
code: "SADA",
|
|
182
|
+
name: "SadaPay",
|
|
183
|
+
type: "emi"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
code: "SAMB",
|
|
187
|
+
name: "Samba Bank Limited",
|
|
188
|
+
type: "commercial"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
code: "SAUD",
|
|
192
|
+
name: "Silkbank Limited (merged into United Bank Limited)",
|
|
193
|
+
type: "commercial",
|
|
194
|
+
mergedInto: "UNIL"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
code: "SBPP",
|
|
198
|
+
name: "State Bank of Pakistan",
|
|
199
|
+
type: "central"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
code: "SCBL",
|
|
203
|
+
name: "Standard Chartered Bank (Pakistan) Limited",
|
|
204
|
+
type: "commercial"
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
code: "SIND",
|
|
208
|
+
name: "Sindh Bank Limited",
|
|
209
|
+
type: "commercial"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
code: "SMES",
|
|
213
|
+
name: "SME Bank Limited",
|
|
214
|
+
type: "specialized"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
code: "SONE",
|
|
218
|
+
name: "Soneri Bank Limited",
|
|
219
|
+
type: "commercial"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
code: "SUMB",
|
|
223
|
+
name: "Bank Makramah Limited (formerly Summit Bank)",
|
|
224
|
+
type: "commercial"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
code: "TAMW",
|
|
228
|
+
name: "easypaisa Digital Bank (formerly Tameer Microfinance Bank)",
|
|
229
|
+
type: "digital",
|
|
230
|
+
aliasOf: "TMFB"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
code: "TMFB",
|
|
234
|
+
name: "easypaisa Digital Bank (formerly Telenor Microfinance Bank)",
|
|
235
|
+
type: "digital"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
code: "UMBL",
|
|
239
|
+
name: "U Microfinance Bank",
|
|
240
|
+
type: "microfinance"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
code: "UNIL",
|
|
244
|
+
name: "United Bank Limited",
|
|
245
|
+
type: "commercial"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
code: "WMBL",
|
|
249
|
+
name: "Mobilink Bank (JazzCash)",
|
|
250
|
+
type: "microfinance",
|
|
251
|
+
aliasOf: "JCMA"
|
|
252
|
+
}
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
// src/iban.ts
|
|
256
|
+
var PK_IBAN_PATTERN = /^PK\d{2}[A-Z]{4}[A-Z0-9]{16}$/;
|
|
257
|
+
var banks = chunkVPBMIYO2_cjs.lazy(
|
|
258
|
+
() => banks_default.map((entry) => ({
|
|
259
|
+
code: entry.code,
|
|
260
|
+
name: entry.name,
|
|
261
|
+
type: entry.type,
|
|
262
|
+
active: entry.mergedInto === void 0,
|
|
263
|
+
mergedInto: entry.mergedInto ?? null,
|
|
264
|
+
aliasOf: entry.aliasOf ?? null
|
|
265
|
+
}))
|
|
266
|
+
);
|
|
267
|
+
var bankByCode = chunkVPBMIYO2_cjs.lazy(
|
|
268
|
+
() => new Map(banks().map((bank) => [bank.code, bank]))
|
|
269
|
+
);
|
|
270
|
+
function expandIbanChars(value) {
|
|
271
|
+
return value.replace(
|
|
272
|
+
/[A-Z]/g,
|
|
273
|
+
(char) => (char.charCodeAt(0) - 55).toString()
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
function mod97(numericIban) {
|
|
277
|
+
let remainder = 0;
|
|
278
|
+
for (const digit of numericIban) {
|
|
279
|
+
remainder = (remainder * 10 + Number(digit)) % 97;
|
|
280
|
+
}
|
|
281
|
+
return remainder;
|
|
282
|
+
}
|
|
283
|
+
function normalizeIBAN(iban) {
|
|
284
|
+
return chunkVPBMIYO2_cjs.stripSeparators(iban).toUpperCase();
|
|
285
|
+
}
|
|
286
|
+
function validateIBAN(iban) {
|
|
287
|
+
const normalized = normalizeIBAN(iban);
|
|
288
|
+
if (!PK_IBAN_PATTERN.test(normalized)) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
const rearranged = normalized.slice(4) + normalized.slice(0, 4);
|
|
292
|
+
return mod97(expandIbanChars(rearranged)) === 1;
|
|
293
|
+
}
|
|
294
|
+
function getBankFromIBAN(iban) {
|
|
295
|
+
if (!validateIBAN(iban)) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return bankByCode().get(normalizeIBAN(iban).slice(4, 8))?.name ?? null;
|
|
299
|
+
}
|
|
300
|
+
function getBankInfo(ibanOrCode) {
|
|
301
|
+
const value = normalizeIBAN(ibanOrCode);
|
|
302
|
+
if (/^[A-Z]{4}$/.test(value)) {
|
|
303
|
+
return bankByCode().get(value) ?? null;
|
|
304
|
+
}
|
|
305
|
+
if (!validateIBAN(value)) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
return bankByCode().get(value.slice(4, 8)) ?? null;
|
|
309
|
+
}
|
|
310
|
+
function getBanks() {
|
|
311
|
+
return banks().map((bank) => ({ ...bank }));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
exports.getBankFromIBAN = getBankFromIBAN;
|
|
315
|
+
exports.getBankInfo = getBankInfo;
|
|
316
|
+
exports.getBanks = getBanks;
|
|
317
|
+
exports.validateIBAN = validateIBAN;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNTD4JLDW_cjs = require('./chunk-NTD4JLDW.cjs');
|
|
4
4
|
var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
|
|
5
5
|
|
|
6
6
|
// data/area-codes.json
|
|
@@ -339,7 +339,7 @@ function groupDigits(digits, size = 3) {
|
|
|
339
339
|
return digits.match(new RegExp(`\\d{1,${size}}`, "g"))?.join("-") ?? digits;
|
|
340
340
|
}
|
|
341
341
|
function analyzeNumber(phone) {
|
|
342
|
-
const mobile =
|
|
342
|
+
const mobile = chunkNTD4JLDW_cjs.normalizePhoneDigits(phone);
|
|
343
343
|
if (mobile !== null) {
|
|
344
344
|
const national2 = mobile.slice(2);
|
|
345
345
|
return {
|