pakdatakit 2.5.1 → 2.7.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 +83 -7
- package/README.md +94 -31
- package/dist/{chunk-LQHM3ADX.js → chunk-33JPVN33.js} +11 -6
- package/dist/{chunk-XCFZKCV2.cjs → chunk-36K225SE.cjs} +14 -9
- package/dist/{chunk-CEPNSHIC.js → chunk-3OCMTNQ7.js} +1 -1
- package/dist/{chunk-YDUXIENX.cjs → chunk-4YLSPXBZ.cjs} +2 -2
- package/dist/{chunk-2OBKPYJZ.cjs → chunk-6AIN4FKB.cjs} +12 -4
- package/dist/chunk-7NTUEHQV.cjs +69 -0
- package/dist/{chunk-KRYHLYN2.js → chunk-BATPA7GN.js} +12 -4
- package/dist/chunk-CKCOK6X4.js +64 -0
- package/dist/{chunk-7DY26QPN.js → chunk-CRYCAMWC.js} +1 -1
- package/dist/{chunk-TVL6RDAU.cjs → chunk-EGF4CINK.cjs} +2 -2
- package/dist/{chunk-XVEG53NN.cjs → chunk-GOGEMCGG.cjs} +84 -0
- package/dist/chunk-NDW52ZK3.js +85 -0
- package/dist/chunk-NLSIAPZG.cjs +90 -0
- package/dist/{chunk-IDTRFOQW.js → chunk-OYQJQE5R.js} +10 -5
- package/dist/{chunk-5RGX4DWF.js → chunk-SGGQ6XB2.js} +46 -14
- package/dist/{chunk-UYFTXD4P.js → chunk-T6K46DGW.js} +1 -1
- package/dist/{chunk-AUQFA7EE.cjs → chunk-VSIVT5RT.cjs} +11 -6
- package/dist/{chunk-H6M6L26S.cjs → chunk-VZIBHQC7.cjs} +2 -2
- package/dist/{chunk-EA3SIHYT.js → chunk-WYNM5ZWY.js} +84 -1
- package/dist/{chunk-5DDHO5Z7.cjs → chunk-XWGSREI5.cjs} +46 -14
- package/dist/class-validator.cjs +18 -9
- package/dist/class-validator.d.cts +12 -3
- package/dist/class-validator.d.ts +12 -3
- package/dist/class-validator.js +17 -9
- package/dist/cli.js +1 -1
- package/dist/cnic.cjs +11 -3
- package/dist/cnic.d.cts +80 -3
- package/dist/cnic.d.ts +80 -3
- package/dist/cnic.js +1 -1
- package/dist/format.cjs +11 -3
- package/dist/format.d.cts +57 -1
- package/dist/format.d.ts +57 -1
- package/dist/format.js +1 -1
- package/dist/incometax.cjs +6 -6
- package/dist/incometax.d.cts +51 -7
- package/dist/incometax.d.ts +51 -7
- package/dist/incometax.js +1 -1
- package/dist/index.cjs +67 -47
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +10 -10
- package/dist/input.cjs +8 -8
- package/dist/input.js +2 -2
- package/dist/joi.cjs +10 -8
- package/dist/joi.d.cts +2 -1
- package/dist/joi.d.ts +2 -1
- package/dist/joi.js +9 -7
- package/dist/numbers.cjs +5 -5
- package/dist/numbers.d.cts +28 -5
- package/dist/numbers.d.ts +28 -5
- package/dist/numbers.js +1 -1
- package/dist/quality.cjs +5 -5
- package/dist/quality.js +2 -2
- package/dist/raast.cjs +5 -5
- package/dist/raast.d.cts +17 -6
- package/dist/raast.d.ts +17 -6
- package/dist/raast.js +1 -1
- package/dist/{rules-GxgPiVws.d.cts → rules-GEELAOfb.d.cts} +5 -0
- package/dist/{rules-GxgPiVws.d.ts → rules-GEELAOfb.d.ts} +5 -0
- package/dist/superstruct.cjs +10 -8
- package/dist/superstruct.d.cts +2 -1
- package/dist/superstruct.d.ts +2 -1
- package/dist/superstruct.js +9 -7
- package/dist/tax.cjs +5 -5
- package/dist/tax.d.cts +8 -2
- package/dist/tax.d.ts +8 -2
- package/dist/tax.js +2 -2
- package/dist/text.cjs +13 -9
- package/dist/text.d.cts +40 -4
- package/dist/text.d.ts +40 -4
- package/dist/text.js +1 -1
- package/dist/valibot.cjs +16 -8
- package/dist/valibot.d.cts +2 -1
- package/dist/valibot.d.ts +2 -1
- package/dist/valibot.js +15 -7
- package/dist/words.d.cts +4 -1
- package/dist/words.d.ts +4 -1
- package/dist/yup.cjs +10 -8
- package/dist/yup.d.cts +2 -1
- package/dist/yup.d.ts +2 -1
- package/dist/yup.js +9 -7
- package/dist/zod.cjs +12 -8
- package/dist/zod.d.cts +2 -1
- package/dist/zod.d.ts +2 -1
- package/dist/zod.js +11 -7
- package/package.json +2 -2
- package/dist/chunk-6TSKA2PH.js +0 -38
- package/dist/chunk-EEVNLTB4.js +0 -32
- package/dist/chunk-HTCSHHOR.cjs +0 -35
- package/dist/chunk-LVHTH4P7.cjs +0 -41
|
@@ -309,5 +309,88 @@ function wrapBidi(text, direction = "auto") {
|
|
|
309
309
|
const open = direction === "rtl" ? "\u2067" : direction === "ltr" ? "\u2066" : "\u2068";
|
|
310
310
|
return `${open}${text}\u2069`;
|
|
311
311
|
}
|
|
312
|
+
var KEY_DIGRAPHS = {
|
|
313
|
+
kh: "kh",
|
|
314
|
+
gh: "g",
|
|
315
|
+
sh: "sh",
|
|
316
|
+
ch: "ch",
|
|
317
|
+
ph: "f",
|
|
318
|
+
th: "t",
|
|
319
|
+
dh: "d",
|
|
320
|
+
bh: "b",
|
|
321
|
+
jh: "j",
|
|
322
|
+
zh: "z",
|
|
323
|
+
ck: "k"
|
|
324
|
+
};
|
|
325
|
+
var KEY_LETTERS = {
|
|
326
|
+
c: "k",
|
|
327
|
+
q: "k",
|
|
328
|
+
v: "w",
|
|
329
|
+
x: "ks"
|
|
330
|
+
};
|
|
331
|
+
var PLAIN_VOWELS = "aeiou";
|
|
332
|
+
function vowelClass(letter) {
|
|
333
|
+
if (letter === "a" || letter === "e") return "a";
|
|
334
|
+
if (letter === "i" || letter === "y") return "i";
|
|
335
|
+
return "u";
|
|
336
|
+
}
|
|
337
|
+
function firstVowelClass(run, wordStart) {
|
|
338
|
+
if (run.startsWith("ee")) return "i";
|
|
339
|
+
if (wordStart && run.startsWith("e")) return "i";
|
|
340
|
+
if (/^[ao][uw]/.test(run)) return "u";
|
|
341
|
+
if (/^(a[iye]|e[iy])/.test(run)) return "e";
|
|
342
|
+
return vowelClass(run[0]);
|
|
343
|
+
}
|
|
344
|
+
function wordKey(word) {
|
|
345
|
+
let letters = "";
|
|
346
|
+
for (let i = 0; i < word.length; ) {
|
|
347
|
+
const pair = KEY_DIGRAPHS[word.slice(i, i + 2)];
|
|
348
|
+
if (pair !== void 0) {
|
|
349
|
+
letters += pair;
|
|
350
|
+
i += 2;
|
|
351
|
+
} else {
|
|
352
|
+
const letter = word[i];
|
|
353
|
+
letters += KEY_LETTERS[letter] ?? letter;
|
|
354
|
+
i += 1;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
letters = letters.replace(/([^e])\1+/g, "$1");
|
|
358
|
+
const vowel = [];
|
|
359
|
+
for (let i = 0; i < letters.length; i += 1) {
|
|
360
|
+
const letter = letters[i];
|
|
361
|
+
vowel.push(
|
|
362
|
+
PLAIN_VOWELS.includes(letter) || letter === "y" && i > 0 || letter === "w" && i > 0 && vowel[i - 1] === true && !PLAIN_VOWELS.includes(letters[i + 1] ?? "")
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const last = letters.length - 1;
|
|
366
|
+
if (last > 0 && letters[last] === "h" && vowel[last - 1] === true) {
|
|
367
|
+
letters = letters.slice(0, last);
|
|
368
|
+
vowel.pop();
|
|
369
|
+
}
|
|
370
|
+
let key = "";
|
|
371
|
+
let firstVowelDone = false;
|
|
372
|
+
for (let i = 0; i < letters.length; ) {
|
|
373
|
+
if (!vowel[i]) {
|
|
374
|
+
key += letters[i];
|
|
375
|
+
i += 1;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
let end = i;
|
|
379
|
+
while (end < letters.length && vowel[end]) end += 1;
|
|
380
|
+
const run = letters.slice(i, end);
|
|
381
|
+
if (!firstVowelDone) {
|
|
382
|
+
key += firstVowelClass(run, i === 0);
|
|
383
|
+
firstVowelDone = true;
|
|
384
|
+
} else if (end === letters.length) {
|
|
385
|
+
key += run.endsWith("ee") ? "i" : vowelClass(run[run.length - 1]);
|
|
386
|
+
}
|
|
387
|
+
i = end;
|
|
388
|
+
}
|
|
389
|
+
return key;
|
|
390
|
+
}
|
|
391
|
+
function romanUrduKey(text) {
|
|
392
|
+
if (typeof text !== "string") return "";
|
|
393
|
+
return text.toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g, "").split(/[^a-z]+/).filter((word) => word !== "").map(wordKey).join(" ");
|
|
394
|
+
}
|
|
312
395
|
|
|
313
|
-
export { compareUrdu, isRTL, normalizeRomanUrdu, normalizeText, slugify, toEnglishDigits, toUrduDigits, wrapBidi };
|
|
396
|
+
export { compareUrdu, isRTL, normalizeRomanUrdu, normalizeText, romanUrduKey, slugify, toEnglishDigits, toUrduDigits, wrapBidi };
|
|
@@ -83,7 +83,8 @@ var income_tax_slabs_default = [
|
|
|
83
83
|
fixed: 2142e4,
|
|
84
84
|
rate: 35
|
|
85
85
|
}
|
|
86
|
-
]
|
|
86
|
+
],
|
|
87
|
+
surcharge: null
|
|
87
88
|
},
|
|
88
89
|
{
|
|
89
90
|
taxYear: 2021,
|
|
@@ -164,7 +165,8 @@ var income_tax_slabs_default = [
|
|
|
164
165
|
fixed: 2142e4,
|
|
165
166
|
rate: 35
|
|
166
167
|
}
|
|
167
|
-
]
|
|
168
|
+
],
|
|
169
|
+
surcharge: null
|
|
168
170
|
},
|
|
169
171
|
{
|
|
170
172
|
taxYear: 2022,
|
|
@@ -245,7 +247,8 @@ var income_tax_slabs_default = [
|
|
|
245
247
|
fixed: 2142e4,
|
|
246
248
|
rate: 35
|
|
247
249
|
}
|
|
248
|
-
]
|
|
250
|
+
],
|
|
251
|
+
surcharge: null
|
|
249
252
|
},
|
|
250
253
|
{
|
|
251
254
|
taxYear: 2023,
|
|
@@ -296,7 +299,8 @@ var income_tax_slabs_default = [
|
|
|
296
299
|
fixed: 2955e3,
|
|
297
300
|
rate: 35
|
|
298
301
|
}
|
|
299
|
-
]
|
|
302
|
+
],
|
|
303
|
+
surcharge: null
|
|
300
304
|
},
|
|
301
305
|
{
|
|
302
306
|
taxYear: 2024,
|
|
@@ -341,7 +345,8 @@ var income_tax_slabs_default = [
|
|
|
341
345
|
fixed: 1095e3,
|
|
342
346
|
rate: 35
|
|
343
347
|
}
|
|
344
|
-
]
|
|
348
|
+
],
|
|
349
|
+
surcharge: null
|
|
345
350
|
},
|
|
346
351
|
{
|
|
347
352
|
taxYear: 2025,
|
|
@@ -386,7 +391,13 @@ var income_tax_slabs_default = [
|
|
|
386
391
|
fixed: 7e5,
|
|
387
392
|
rate: 35
|
|
388
393
|
}
|
|
389
|
-
]
|
|
394
|
+
],
|
|
395
|
+
surcharge: {
|
|
396
|
+
rate: 10,
|
|
397
|
+
over: 1e7,
|
|
398
|
+
law: "Income Tax Ordinance 2001, s. 4AB, inserted by the Finance Act 2024, s. 8(2): 10% of the tax under Division I where taxable income exceeds Rs 10 million",
|
|
399
|
+
source: "https://download1.fbr.gov.pk/Docs/2024630146346801FinanceAct-2024.pdf"
|
|
400
|
+
}
|
|
390
401
|
},
|
|
391
402
|
{
|
|
392
403
|
taxYear: 2026,
|
|
@@ -431,7 +442,13 @@ var income_tax_slabs_default = [
|
|
|
431
442
|
fixed: 616e3,
|
|
432
443
|
rate: 35
|
|
433
444
|
}
|
|
434
|
-
]
|
|
445
|
+
],
|
|
446
|
+
surcharge: {
|
|
447
|
+
rate: 9,
|
|
448
|
+
over: 1e7,
|
|
449
|
+
law: "Income Tax Ordinance 2001, s. 4AB, proviso added by the Finance Act 2025: 9% for an individual with income under the head Salary, where taxable income exceeds Rs 10 million",
|
|
450
|
+
source: "https://download1.fbr.gov.pk/Docs/2025881983148210Income-Tax-Ordinance,-2001-Amended-upto-31.07.2025.pdf"
|
|
451
|
+
}
|
|
435
452
|
},
|
|
436
453
|
{
|
|
437
454
|
taxYear: 2027,
|
|
@@ -488,7 +505,13 @@ var income_tax_slabs_default = [
|
|
|
488
505
|
fixed: 1424e3,
|
|
489
506
|
rate: 35
|
|
490
507
|
}
|
|
491
|
-
]
|
|
508
|
+
],
|
|
509
|
+
surcharge: {
|
|
510
|
+
rate: 0,
|
|
511
|
+
over: 1e7,
|
|
512
|
+
law: "Income Tax Ordinance 2001, s. 4AB, proviso substituted by the Finance Act 2026, s. 5(2)(b): no surcharge for an individual with income under the head Salary",
|
|
513
|
+
source: "https://download1.fbr.gov.pk/Docs/20266291261044366FinanceAct2026.pdf"
|
|
514
|
+
}
|
|
492
515
|
}
|
|
493
516
|
];
|
|
494
517
|
|
|
@@ -519,7 +542,8 @@ function findYear(options) {
|
|
|
519
542
|
}
|
|
520
543
|
var copyYear = (year) => ({
|
|
521
544
|
...year,
|
|
522
|
-
slabs: year.slabs.map((slab) => ({ ...slab }))
|
|
545
|
+
slabs: year.slabs.map((slab) => ({ ...slab })),
|
|
546
|
+
surcharge: year.surcharge === null ? null : { ...year.surcharge }
|
|
523
547
|
});
|
|
524
548
|
function getSalaryTaxSlabs(taxYear) {
|
|
525
549
|
const year = findYear(taxYear === void 0 ? void 0 : { taxYear });
|
|
@@ -528,7 +552,7 @@ function getSalaryTaxSlabs(taxYear) {
|
|
|
528
552
|
function getSalaryTaxYears() {
|
|
529
553
|
return YEARS.map((y) => y.taxYear);
|
|
530
554
|
}
|
|
531
|
-
function compute(incomePaisa, year) {
|
|
555
|
+
function compute(incomePaisa, year, includeSurcharge) {
|
|
532
556
|
const slabs = year.slabs;
|
|
533
557
|
let slab = slabs[0];
|
|
534
558
|
for (const candidate of slabs) {
|
|
@@ -537,10 +561,18 @@ function compute(incomePaisa, year) {
|
|
|
537
561
|
const rateBp = Math.round(slab.rate * 100);
|
|
538
562
|
const above = BigInt(incomePaisa - slab.over * 100);
|
|
539
563
|
const taxPaisa = incomePaisa > slab.over * 100 ? slab.fixed * 100 + chunkSF4ECUZ6_cjs.divideHalfUp(above * BigInt(rateBp), 10000n) : slab.fixed * 100;
|
|
564
|
+
const surcharge = year.surcharge;
|
|
565
|
+
const surchargePaisa = includeSurcharge && surcharge !== null && surcharge.rate > 0 && incomePaisa > surcharge.over * 100 ? chunkSF4ECUZ6_cjs.divideHalfUp(
|
|
566
|
+
BigInt(taxPaisa) * BigInt(Math.round(surcharge.rate * 100)),
|
|
567
|
+
10000n
|
|
568
|
+
) : 0;
|
|
569
|
+
const totalPaisa = taxPaisa + surchargePaisa;
|
|
540
570
|
return {
|
|
541
571
|
tax: chunkSF4ECUZ6_cjs.fromPaisa(taxPaisa),
|
|
542
|
-
|
|
543
|
-
|
|
572
|
+
surcharge: chunkSF4ECUZ6_cjs.fromPaisa(surchargePaisa),
|
|
573
|
+
total: chunkSF4ECUZ6_cjs.fromPaisa(totalPaisa),
|
|
574
|
+
monthly: chunkSF4ECUZ6_cjs.fromPaisa(chunkSF4ECUZ6_cjs.divideHalfUp(BigInt(totalPaisa), 12n)),
|
|
575
|
+
effectiveRate: incomePaisa === 0 ? 0 : chunkSF4ECUZ6_cjs.divideHalfUp(BigInt(totalPaisa) * 10000n, BigInt(incomePaisa)) / 100,
|
|
544
576
|
slab: { ...slab },
|
|
545
577
|
taxYear: year.taxYear
|
|
546
578
|
};
|
|
@@ -549,13 +581,13 @@ function calculateSalaryTax(annualIncome, options) {
|
|
|
549
581
|
const paisa = chunkSF4ECUZ6_cjs.toUnits(annualIncome, 2);
|
|
550
582
|
if (paisa === null) return null;
|
|
551
583
|
const year = findYear(options);
|
|
552
|
-
return year ? compute(paisa, year) : null;
|
|
584
|
+
return year ? compute(paisa, year, options?.includeSurcharge === true) : null;
|
|
553
585
|
}
|
|
554
586
|
function calculateMonthlySalaryTax(monthlySalary, options) {
|
|
555
587
|
const paisa = chunkSF4ECUZ6_cjs.toUnits(monthlySalary, 2);
|
|
556
588
|
if (paisa === null) return null;
|
|
557
589
|
const year = findYear(options);
|
|
558
|
-
return year ? compute(paisa * 12, year) : null;
|
|
590
|
+
return year ? compute(paisa * 12, year, options?.includeSurcharge === true) : null;
|
|
559
591
|
}
|
|
560
592
|
|
|
561
593
|
exports.calculateMonthlySalaryTax = calculateMonthlySalaryTax;
|
package/dist/class-validator.cjs
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk36K225SE_cjs = require('./chunk-36K225SE.cjs');
|
|
4
4
|
require('./chunk-ESKXG7Y6.cjs');
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-4YLSPXBZ.cjs');
|
|
6
|
+
require('./chunk-VZIBHQC7.cjs');
|
|
7
7
|
require('./chunk-SQIHFEXI.cjs');
|
|
8
8
|
require('./chunk-DHOP7LQX.cjs');
|
|
9
9
|
require('./chunk-MTS6SVNP.cjs');
|
|
10
|
-
require('./chunk-
|
|
10
|
+
require('./chunk-VSIVT5RT.cjs');
|
|
11
11
|
require('./chunk-YTLE5K7G.cjs');
|
|
12
12
|
require('./chunk-7E7L3NYS.cjs');
|
|
13
13
|
require('./chunk-QFPEFD67.cjs');
|
|
14
14
|
require('./chunk-I7UUPD3G.cjs');
|
|
15
|
-
require('./chunk-
|
|
15
|
+
require('./chunk-7NTUEHQV.cjs');
|
|
16
|
+
require('./chunk-NLSIAPZG.cjs');
|
|
16
17
|
require('./chunk-33GOK7EE.cjs');
|
|
17
18
|
require('./chunk-E6GWBOKV.cjs');
|
|
18
19
|
require('./chunk-VPBMIYO2.cjs');
|
|
19
20
|
var classValidator = require('class-validator');
|
|
20
21
|
|
|
21
22
|
function decorator(name) {
|
|
22
|
-
const rule =
|
|
23
|
+
const rule = chunk36K225SE_cjs.RULES[name];
|
|
23
24
|
return (options = {}) => (target, propertyName) => {
|
|
25
|
+
const { services, ...validationOptions } = options;
|
|
26
|
+
const ruleOptions = { services: services === true };
|
|
24
27
|
classValidator.registerDecorator({
|
|
25
28
|
name: `pk-${name}`,
|
|
26
29
|
target: target.constructor,
|
|
27
30
|
propertyName,
|
|
28
|
-
options: {
|
|
31
|
+
options: {
|
|
32
|
+
...validationOptions,
|
|
33
|
+
message: options.message ?? rule.message
|
|
34
|
+
},
|
|
29
35
|
validator: {
|
|
30
|
-
validate: (value) => typeof value === "string" && rule.test(value)
|
|
36
|
+
validate: (value) => typeof value === "string" && rule.test(value, ruleOptions)
|
|
31
37
|
}
|
|
32
38
|
});
|
|
33
39
|
};
|
|
@@ -41,7 +47,8 @@ var pk = {
|
|
|
41
47
|
landline: decorator("landline"),
|
|
42
48
|
passport: decorator("passport"),
|
|
43
49
|
vehiclePlate: decorator("vehiclePlate"),
|
|
44
|
-
codPhone: decorator("codPhone")
|
|
50
|
+
codPhone: decorator("codPhone"),
|
|
51
|
+
amount: decorator("amount")
|
|
45
52
|
};
|
|
46
53
|
var IsCNIC = pk.cnic;
|
|
47
54
|
var IsPakPhone = pk.phone;
|
|
@@ -52,10 +59,12 @@ var IsPakLandline = pk.landline;
|
|
|
52
59
|
var IsPakPassport = pk.passport;
|
|
53
60
|
var IsVehiclePlate = pk.vehiclePlate;
|
|
54
61
|
var IsCodPhone = pk.codPhone;
|
|
62
|
+
var IsPakAmount = pk.amount;
|
|
55
63
|
|
|
56
64
|
exports.IsCNIC = IsCNIC;
|
|
57
65
|
exports.IsCodPhone = IsCodPhone;
|
|
58
66
|
exports.IsNTN = IsNTN;
|
|
67
|
+
exports.IsPakAmount = IsPakAmount;
|
|
59
68
|
exports.IsPakIBAN = IsPakIBAN;
|
|
60
69
|
exports.IsPakLandline = IsPakLandline;
|
|
61
70
|
exports.IsPakPassport = IsPakPassport;
|
|
@@ -2,9 +2,12 @@ import { ValidationOptions } from 'class-validator';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for the decorators: class-validator's own options (`groups`,
|
|
5
|
-
* `each`, `always`, `context`), plus a custom `message`.
|
|
5
|
+
* `each`, `always`, `context`), plus a custom `message`. `IsPakLandline`
|
|
6
|
+
* also takes `services: true` to accept UAN, toll-free and premium numbers.
|
|
6
7
|
*/
|
|
7
|
-
type DecoratorOptions = ValidationOptions
|
|
8
|
+
type DecoratorOptions = ValidationOptions & {
|
|
9
|
+
services?: boolean;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
* class-validator decorators for Pakistani identifiers. They work in NestJS
|
|
10
13
|
* DTOs with the built-in `ValidationPipe`; no NestJS package is needed.
|
|
@@ -33,6 +36,7 @@ declare const pk: {
|
|
|
33
36
|
passport: (options?: DecoratorOptions) => PropertyDecorator;
|
|
34
37
|
vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
35
38
|
codPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
39
|
+
amount: (options?: DecoratorOptions) => PropertyDecorator;
|
|
36
40
|
};
|
|
37
41
|
/** Validates a CNIC. See {@link pk}. */
|
|
38
42
|
declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
|
|
@@ -58,6 +62,11 @@ declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
|
58
62
|
* `phoneRiskSignals` flag. See {@link pk}.
|
|
59
63
|
*/
|
|
60
64
|
declare const IsCodPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
65
|
+
/**
|
|
66
|
+
* Validates a rupee amount as people type it (`150,000`, `Rs. 1,50,000/-`,
|
|
67
|
+
* `1.5 lakh`): one that `parseAmount` reads. See {@link pk}.
|
|
68
|
+
*/
|
|
69
|
+
declare const IsPakAmount: (options?: DecoratorOptions) => PropertyDecorator;
|
|
61
70
|
|
|
62
|
-
export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
71
|
+
export { IsCNIC, IsCodPhone, IsNTN, IsPakAmount, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
63
72
|
export type { DecoratorOptions };
|
|
@@ -2,9 +2,12 @@ import { ValidationOptions } from 'class-validator';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Options for the decorators: class-validator's own options (`groups`,
|
|
5
|
-
* `each`, `always`, `context`), plus a custom `message`.
|
|
5
|
+
* `each`, `always`, `context`), plus a custom `message`. `IsPakLandline`
|
|
6
|
+
* also takes `services: true` to accept UAN, toll-free and premium numbers.
|
|
6
7
|
*/
|
|
7
|
-
type DecoratorOptions = ValidationOptions
|
|
8
|
+
type DecoratorOptions = ValidationOptions & {
|
|
9
|
+
services?: boolean;
|
|
10
|
+
};
|
|
8
11
|
/**
|
|
9
12
|
* class-validator decorators for Pakistani identifiers. They work in NestJS
|
|
10
13
|
* DTOs with the built-in `ValidationPipe`; no NestJS package is needed.
|
|
@@ -33,6 +36,7 @@ declare const pk: {
|
|
|
33
36
|
passport: (options?: DecoratorOptions) => PropertyDecorator;
|
|
34
37
|
vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
35
38
|
codPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
39
|
+
amount: (options?: DecoratorOptions) => PropertyDecorator;
|
|
36
40
|
};
|
|
37
41
|
/** Validates a CNIC. See {@link pk}. */
|
|
38
42
|
declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
|
|
@@ -58,6 +62,11 @@ declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
|
|
|
58
62
|
* `phoneRiskSignals` flag. See {@link pk}.
|
|
59
63
|
*/
|
|
60
64
|
declare const IsCodPhone: (options?: DecoratorOptions) => PropertyDecorator;
|
|
65
|
+
/**
|
|
66
|
+
* Validates a rupee amount as people type it (`150,000`, `Rs. 1,50,000/-`,
|
|
67
|
+
* `1.5 lakh`): one that `parseAmount` reads. See {@link pk}.
|
|
68
|
+
*/
|
|
69
|
+
declare const IsPakAmount: (options?: DecoratorOptions) => PropertyDecorator;
|
|
61
70
|
|
|
62
|
-
export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
71
|
+
export { IsCNIC, IsCodPhone, IsNTN, IsPakAmount, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
63
72
|
export type { DecoratorOptions };
|
package/dist/class-validator.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { RULES } from './chunk-
|
|
1
|
+
import { RULES } from './chunk-OYQJQE5R.js';
|
|
2
2
|
import './chunk-S274QFFB.js';
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
import './chunk-T6K46DGW.js';
|
|
4
|
+
import './chunk-3OCMTNQ7.js';
|
|
5
5
|
import './chunk-RZQJAZKC.js';
|
|
6
6
|
import './chunk-IBZPJS4H.js';
|
|
7
7
|
import './chunk-V2XE3NCG.js';
|
|
8
|
-
import './chunk-
|
|
8
|
+
import './chunk-33JPVN33.js';
|
|
9
9
|
import './chunk-P7LVE2TF.js';
|
|
10
10
|
import './chunk-E6HSKRAE.js';
|
|
11
11
|
import './chunk-B7DOQ5QF.js';
|
|
12
12
|
import './chunk-33QMFE2Z.js';
|
|
13
|
-
import './chunk-
|
|
13
|
+
import './chunk-CKCOK6X4.js';
|
|
14
|
+
import './chunk-NDW52ZK3.js';
|
|
14
15
|
import './chunk-XOTCIXY6.js';
|
|
15
16
|
import './chunk-E2XU6NOW.js';
|
|
16
17
|
import './chunk-ENQ7O7VW.js';
|
|
@@ -19,13 +20,18 @@ import { registerDecorator } from 'class-validator';
|
|
|
19
20
|
function decorator(name) {
|
|
20
21
|
const rule = RULES[name];
|
|
21
22
|
return (options = {}) => (target, propertyName) => {
|
|
23
|
+
const { services, ...validationOptions } = options;
|
|
24
|
+
const ruleOptions = { services: services === true };
|
|
22
25
|
registerDecorator({
|
|
23
26
|
name: `pk-${name}`,
|
|
24
27
|
target: target.constructor,
|
|
25
28
|
propertyName,
|
|
26
|
-
options: {
|
|
29
|
+
options: {
|
|
30
|
+
...validationOptions,
|
|
31
|
+
message: options.message ?? rule.message
|
|
32
|
+
},
|
|
27
33
|
validator: {
|
|
28
|
-
validate: (value) => typeof value === "string" && rule.test(value)
|
|
34
|
+
validate: (value) => typeof value === "string" && rule.test(value, ruleOptions)
|
|
29
35
|
}
|
|
30
36
|
});
|
|
31
37
|
};
|
|
@@ -39,7 +45,8 @@ var pk = {
|
|
|
39
45
|
landline: decorator("landline"),
|
|
40
46
|
passport: decorator("passport"),
|
|
41
47
|
vehiclePlate: decorator("vehiclePlate"),
|
|
42
|
-
codPhone: decorator("codPhone")
|
|
48
|
+
codPhone: decorator("codPhone"),
|
|
49
|
+
amount: decorator("amount")
|
|
43
50
|
};
|
|
44
51
|
var IsCNIC = pk.cnic;
|
|
45
52
|
var IsPakPhone = pk.phone;
|
|
@@ -50,5 +57,6 @@ var IsPakLandline = pk.landline;
|
|
|
50
57
|
var IsPakPassport = pk.passport;
|
|
51
58
|
var IsVehiclePlate = pk.vehiclePlate;
|
|
52
59
|
var IsCodPhone = pk.codPhone;
|
|
60
|
+
var IsPakAmount = pk.amount;
|
|
53
61
|
|
|
54
|
-
export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
|
62
|
+
export { IsCNIC, IsCodPhone, IsNTN, IsPakAmount, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { normalizeRomanUrdu, formatHijri, toHijri, formatPKR, formatLakh, parseAddress, getCityByPostalCode, getPostalCode, getProvince, getBankFromIBAN, validateIBAN, analyzePhone, validatePhone, validateCNIC } from 'pakdatakit';
|
|
3
3
|
|
|
4
4
|
// package.json
|
|
5
|
-
var version = "2.
|
|
5
|
+
var version = "2.7.0";
|
|
6
6
|
var EXIT_OK = 0;
|
|
7
7
|
var EXIT_NEGATIVE = 1;
|
|
8
8
|
var EXIT_USAGE = 2;
|
package/dist/cnic.cjs
CHANGED
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk7NTUEHQV_cjs = require('./chunk-7NTUEHQV.cjs');
|
|
4
4
|
require('./chunk-VPBMIYO2.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
Object.defineProperty(exports, "findCNICs", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function () { return chunk7NTUEHQV_cjs.findCNICs; }
|
|
11
|
+
});
|
|
8
12
|
Object.defineProperty(exports, "getCNICInfo", {
|
|
9
13
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk7NTUEHQV_cjs.getCNICInfo; }
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "maskCNICs", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return chunk7NTUEHQV_cjs.maskCNICs; }
|
|
11
19
|
});
|
|
12
20
|
Object.defineProperty(exports, "validateCNIC", {
|
|
13
21
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunk7NTUEHQV_cjs.validateCNIC; }
|
|
15
23
|
});
|
package/dist/cnic.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validates a Pakistani CNIC number
|
|
2
|
+
* Validates the format of a Pakistani CNIC number: 13 digits, in 5-7-1
|
|
3
|
+
* groups or together, starting with a province code from 1 to 8.
|
|
3
4
|
*
|
|
4
5
|
* Accepts `3520212345671`, `35202-1234567-1`, `35202 1234567 1` and Urdu digits.
|
|
5
6
|
* Separators must sit between the 5-7-1 digit groups and be used consistently.
|
|
@@ -31,6 +32,82 @@ interface CNICInfo {
|
|
|
31
32
|
* @returns Decoded information, or `null` if the CNIC is invalid
|
|
32
33
|
*/
|
|
33
34
|
declare function getCNICInfo(cnic: string): CNICInfo | null;
|
|
35
|
+
/**
|
|
36
|
+
* A CNIC that {@link findCNICs} found in free text: as written, its digits,
|
|
37
|
+
* its formatted form and where it is in the text.
|
|
38
|
+
*/
|
|
39
|
+
interface CNICMatch {
|
|
40
|
+
/** The text as written, e.g. `35202 1234567-1` or with Urdu digits. */
|
|
41
|
+
raw: string;
|
|
42
|
+
/** The 13 digits, in ASCII. */
|
|
43
|
+
digits: string;
|
|
44
|
+
/** The CNIC in `#####-#######-#` form. */
|
|
45
|
+
formatted: string;
|
|
46
|
+
/** Offset of the first character in the text (UTF-16 code units). */
|
|
47
|
+
start: number;
|
|
48
|
+
/** Offset just after the last character (UTF-16 code units). */
|
|
49
|
+
end: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Finds CNIC numbers in free text, such as a chat message, a note or an
|
|
53
|
+
* uploaded document, for example to mask them before logging.
|
|
54
|
+
*
|
|
55
|
+
* A match is 13 digits whose first digit is a province code (1-8), written
|
|
56
|
+
* together or in 5-7-1 groups with a hyphen, dash, dot or space between the
|
|
57
|
+
* groups (the two separators may differ). Digits may be ASCII, Urdu or
|
|
58
|
+
* Arabic-Indic, even mixed. A match never starts or ends next to another
|
|
59
|
+
* digit, so a longer number is not cut into a CNIC.
|
|
60
|
+
*
|
|
61
|
+
* This is looser than {@link validateCNIC}, which needs the same separator
|
|
62
|
+
* twice: text is written carelessly. It is a pattern match, so any other
|
|
63
|
+
* 13-digit number that starts with 1-8 (an account or order number, say) also
|
|
64
|
+
* matches.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* findCNICs('CNIC: 35202-1234567-1, phone 0300-1234567');
|
|
68
|
+
* // [{ raw: '35202-1234567-1', digits: '3520212345671',
|
|
69
|
+
* // formatted: '35202-1234567-1', start: 6, end: 21 }]
|
|
70
|
+
*
|
|
71
|
+
* @param text - Any text
|
|
72
|
+
* @returns The matches in order, or `[]` (also for a value that is not a
|
|
73
|
+
* string). Never throws.
|
|
74
|
+
*/
|
|
75
|
+
declare function findCNICs(text: string): CNICMatch[];
|
|
76
|
+
/** Options for {@link maskCNICs}. */
|
|
77
|
+
interface MaskCNICsOptions {
|
|
78
|
+
/** What each digit is replaced with. Default `'X'`. */
|
|
79
|
+
mask?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* What {@link maskCNICs} returns: the text with every CNIC's digits masked,
|
|
83
|
+
* and how many CNICs it masked.
|
|
84
|
+
*/
|
|
85
|
+
interface MaskedText {
|
|
86
|
+
/** The text with every CNIC's digits masked; separators are kept. */
|
|
87
|
+
text: string;
|
|
88
|
+
/** How many CNICs were masked. */
|
|
89
|
+
count: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Masks every CNIC in free text, as found by {@link findCNICs}: each digit
|
|
93
|
+
* becomes the mask and the separators stay, so `35202-1234567-1` becomes
|
|
94
|
+
* `XXXXX-XXXXXXX-X`. The rest of the text is unchanged.
|
|
95
|
+
*
|
|
96
|
+
* Like {@link findCNICs}, it also masks any other 13-digit number that
|
|
97
|
+
* starts with 1-8.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* maskCNICs('My CNIC is 35202-1234567-1');
|
|
101
|
+
* // { text: 'My CNIC is XXXXX-XXXXXXX-X', count: 1 }
|
|
102
|
+
* maskCNICs('35202 1234567 1', { mask: '*' });
|
|
103
|
+
* // { text: '***** ******* *', count: 1 }
|
|
104
|
+
*
|
|
105
|
+
* @param text - Any text
|
|
106
|
+
* @param options - `mask`: the string that replaces each digit
|
|
107
|
+
* @returns The masked text and the number of CNICs masked. A value that is
|
|
108
|
+
* not a string gives `{ text: '', count: 0 }`. Never throws.
|
|
109
|
+
*/
|
|
110
|
+
declare function maskCNICs(text: string, options?: MaskCNICsOptions): MaskedText;
|
|
34
111
|
|
|
35
|
-
export { getCNICInfo, validateCNIC };
|
|
36
|
-
export type { CNICInfo };
|
|
112
|
+
export { findCNICs, getCNICInfo, maskCNICs, validateCNIC };
|
|
113
|
+
export type { CNICInfo, CNICMatch, MaskCNICsOptions, MaskedText };
|
package/dist/cnic.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validates a Pakistani CNIC number
|
|
2
|
+
* Validates the format of a Pakistani CNIC number: 13 digits, in 5-7-1
|
|
3
|
+
* groups or together, starting with a province code from 1 to 8.
|
|
3
4
|
*
|
|
4
5
|
* Accepts `3520212345671`, `35202-1234567-1`, `35202 1234567 1` and Urdu digits.
|
|
5
6
|
* Separators must sit between the 5-7-1 digit groups and be used consistently.
|
|
@@ -31,6 +32,82 @@ interface CNICInfo {
|
|
|
31
32
|
* @returns Decoded information, or `null` if the CNIC is invalid
|
|
32
33
|
*/
|
|
33
34
|
declare function getCNICInfo(cnic: string): CNICInfo | null;
|
|
35
|
+
/**
|
|
36
|
+
* A CNIC that {@link findCNICs} found in free text: as written, its digits,
|
|
37
|
+
* its formatted form and where it is in the text.
|
|
38
|
+
*/
|
|
39
|
+
interface CNICMatch {
|
|
40
|
+
/** The text as written, e.g. `35202 1234567-1` or with Urdu digits. */
|
|
41
|
+
raw: string;
|
|
42
|
+
/** The 13 digits, in ASCII. */
|
|
43
|
+
digits: string;
|
|
44
|
+
/** The CNIC in `#####-#######-#` form. */
|
|
45
|
+
formatted: string;
|
|
46
|
+
/** Offset of the first character in the text (UTF-16 code units). */
|
|
47
|
+
start: number;
|
|
48
|
+
/** Offset just after the last character (UTF-16 code units). */
|
|
49
|
+
end: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Finds CNIC numbers in free text, such as a chat message, a note or an
|
|
53
|
+
* uploaded document, for example to mask them before logging.
|
|
54
|
+
*
|
|
55
|
+
* A match is 13 digits whose first digit is a province code (1-8), written
|
|
56
|
+
* together or in 5-7-1 groups with a hyphen, dash, dot or space between the
|
|
57
|
+
* groups (the two separators may differ). Digits may be ASCII, Urdu or
|
|
58
|
+
* Arabic-Indic, even mixed. A match never starts or ends next to another
|
|
59
|
+
* digit, so a longer number is not cut into a CNIC.
|
|
60
|
+
*
|
|
61
|
+
* This is looser than {@link validateCNIC}, which needs the same separator
|
|
62
|
+
* twice: text is written carelessly. It is a pattern match, so any other
|
|
63
|
+
* 13-digit number that starts with 1-8 (an account or order number, say) also
|
|
64
|
+
* matches.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* findCNICs('CNIC: 35202-1234567-1, phone 0300-1234567');
|
|
68
|
+
* // [{ raw: '35202-1234567-1', digits: '3520212345671',
|
|
69
|
+
* // formatted: '35202-1234567-1', start: 6, end: 21 }]
|
|
70
|
+
*
|
|
71
|
+
* @param text - Any text
|
|
72
|
+
* @returns The matches in order, or `[]` (also for a value that is not a
|
|
73
|
+
* string). Never throws.
|
|
74
|
+
*/
|
|
75
|
+
declare function findCNICs(text: string): CNICMatch[];
|
|
76
|
+
/** Options for {@link maskCNICs}. */
|
|
77
|
+
interface MaskCNICsOptions {
|
|
78
|
+
/** What each digit is replaced with. Default `'X'`. */
|
|
79
|
+
mask?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* What {@link maskCNICs} returns: the text with every CNIC's digits masked,
|
|
83
|
+
* and how many CNICs it masked.
|
|
84
|
+
*/
|
|
85
|
+
interface MaskedText {
|
|
86
|
+
/** The text with every CNIC's digits masked; separators are kept. */
|
|
87
|
+
text: string;
|
|
88
|
+
/** How many CNICs were masked. */
|
|
89
|
+
count: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Masks every CNIC in free text, as found by {@link findCNICs}: each digit
|
|
93
|
+
* becomes the mask and the separators stay, so `35202-1234567-1` becomes
|
|
94
|
+
* `XXXXX-XXXXXXX-X`. The rest of the text is unchanged.
|
|
95
|
+
*
|
|
96
|
+
* Like {@link findCNICs}, it also masks any other 13-digit number that
|
|
97
|
+
* starts with 1-8.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* maskCNICs('My CNIC is 35202-1234567-1');
|
|
101
|
+
* // { text: 'My CNIC is XXXXX-XXXXXXX-X', count: 1 }
|
|
102
|
+
* maskCNICs('35202 1234567 1', { mask: '*' });
|
|
103
|
+
* // { text: '***** ******* *', count: 1 }
|
|
104
|
+
*
|
|
105
|
+
* @param text - Any text
|
|
106
|
+
* @param options - `mask`: the string that replaces each digit
|
|
107
|
+
* @returns The masked text and the number of CNICs masked. A value that is
|
|
108
|
+
* not a string gives `{ text: '', count: 0 }`. Never throws.
|
|
109
|
+
*/
|
|
110
|
+
declare function maskCNICs(text: string, options?: MaskCNICsOptions): MaskedText;
|
|
34
111
|
|
|
35
|
-
export { getCNICInfo, validateCNIC };
|
|
36
|
-
export type { CNICInfo };
|
|
112
|
+
export { findCNICs, getCNICInfo, maskCNICs, validateCNIC };
|
|
113
|
+
export type { CNICInfo, CNICMatch, MaskCNICsOptions, MaskedText };
|
package/dist/cnic.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { getCNICInfo, validateCNIC } from './chunk-
|
|
1
|
+
export { findCNICs, getCNICInfo, maskCNICs, validateCNIC } from './chunk-CKCOK6X4.js';
|
|
2
2
|
import './chunk-ENQ7O7VW.js';
|