pakdatakit 2.2.1 → 2.3.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.
Files changed (103) hide show
  1. package/DATA.md +302 -33
  2. package/README.md +172 -27
  3. package/dist/address.cjs +5 -5
  4. package/dist/address.js +3 -3
  5. package/dist/{chunk-4VSGCQ6K.cjs → chunk-2OBKPYJZ.cjs} +3 -3
  6. package/dist/chunk-33QMFE2Z.js +21244 -0
  7. package/dist/chunk-7E7L3NYS.cjs +11 -0
  8. package/dist/{chunk-TTARJWGT.js → chunk-A3HBEBXY.js} +2 -2
  9. package/dist/{chunk-3ZA265SK.cjs → chunk-AUQFA7EE.cjs} +172 -4
  10. package/dist/{chunk-HBOZIITD.js → chunk-CADQM4ZN.js} +14 -14
  11. package/dist/{chunk-3IARSCO6.cjs → chunk-DHOP7LQX.cjs} +25 -14
  12. package/dist/chunk-E6HSKRAE.js +9 -0
  13. package/dist/{chunk-33FXHM2E.cjs → chunk-ESKXG7Y6.cjs} +5 -5
  14. package/dist/{chunk-U7MWHXMF.cjs → chunk-FRBPAGEJ.cjs} +4 -4
  15. package/dist/chunk-I7UUPD3G.cjs +21252 -0
  16. package/dist/{chunk-YPPKY5XZ.js → chunk-IBZPJS4H.js} +26 -15
  17. package/dist/{chunk-47P7HILD.cjs → chunk-J5ARB4TE.cjs} +8 -8
  18. package/dist/{chunk-XCXFGTHW.cjs → chunk-J5ZF46NZ.cjs} +14 -14
  19. package/dist/{chunk-NZQ47NWD.js → chunk-KRYHLYN2.js} +1 -1
  20. package/dist/{chunk-RXNYY5K5.js → chunk-LQHM3ADX.js} +172 -4
  21. package/dist/{chunk-HTERSQGF.cjs → chunk-MTS6SVNP.cjs} +4 -4
  22. package/dist/chunk-N4S22XX3.js +6208 -0
  23. package/dist/chunk-OKMBYX3F.cjs +6220 -0
  24. package/dist/{chunk-6IPPANNX.js → chunk-P7LVE2TF.js} +2 -2
  25. package/dist/chunk-RZQJAZKC.js +22 -0
  26. package/dist/{chunk-PLDVGOKZ.js → chunk-S274QFFB.js} +2 -2
  27. package/dist/chunk-SQIHFEXI.cjs +25 -0
  28. package/dist/chunk-TBTWZC74.cjs +32 -0
  29. package/dist/{chunk-NAJGGUAM.cjs → chunk-TC3VRWZV.cjs} +2 -2
  30. package/dist/{chunk-QKH7W2CC.js → chunk-TQP2T33V.js} +5 -5
  31. package/dist/{chunk-AZV45DMG.js → chunk-V2XE3NCG.js} +2 -2
  32. package/dist/{chunk-NTD4JLDW.cjs → chunk-YTLE5K7G.cjs} +1 -1
  33. package/dist/{chunk-HUQY2WR5.js → chunk-YTSMFGTW.js} +13 -3
  34. package/dist/{chunk-EMH4IP2U.js → chunk-ZRONAQBV.js} +1 -1
  35. package/dist/class-validator.cjs +57 -0
  36. package/dist/class-validator.d.cts +57 -0
  37. package/dist/class-validator.d.ts +57 -0
  38. package/dist/class-validator.js +47 -0
  39. package/dist/cli.js +1 -1
  40. package/dist/geo.cjs +22 -6
  41. package/dist/geo.d.cts +56 -1
  42. package/dist/geo.d.ts +56 -1
  43. package/dist/geo.js +1 -1
  44. package/dist/holidays.cjs +4 -4
  45. package/dist/holidays.js +1 -1
  46. package/dist/iban.cjs +5 -5
  47. package/dist/iban.d.cts +8 -6
  48. package/dist/iban.d.ts +8 -6
  49. package/dist/iban.js +1 -1
  50. package/dist/index.cjs +106 -68
  51. package/dist/index.d.cts +5 -3
  52. package/dist/index.d.ts +5 -3
  53. package/dist/index.js +16 -14
  54. package/dist/input.cjs +9 -9
  55. package/dist/input.js +3 -3
  56. package/dist/joi.cjs +37 -0
  57. package/dist/joi.d.cts +24 -0
  58. package/dist/joi.d.ts +24 -0
  59. package/dist/joi.js +31 -0
  60. package/dist/networks.cjs +3 -3
  61. package/dist/networks.js +2 -2
  62. package/dist/numbers.cjs +6 -6
  63. package/dist/numbers.js +2 -2
  64. package/dist/passport.cjs +11 -0
  65. package/dist/passport.d.cts +27 -0
  66. package/dist/passport.d.ts +27 -0
  67. package/dist/passport.js +2 -0
  68. package/dist/phone.cjs +8 -8
  69. package/dist/phone.js +3 -3
  70. package/dist/postal.cjs +14 -6
  71. package/dist/postal.d.cts +54 -2
  72. package/dist/postal.d.ts +54 -2
  73. package/dist/postal.js +1 -1
  74. package/dist/raast.cjs +6 -6
  75. package/dist/raast.js +2 -2
  76. package/dist/superstruct.cjs +35 -0
  77. package/dist/superstruct.d.cts +24 -0
  78. package/dist/superstruct.d.ts +24 -0
  79. package/dist/superstruct.js +33 -0
  80. package/dist/valibot.cjs +12 -8
  81. package/dist/valibot.d.cts +2 -0
  82. package/dist/valibot.d.ts +2 -0
  83. package/dist/valibot.js +11 -7
  84. package/dist/vehicle.cjs +15 -0
  85. package/dist/vehicle.d.cts +43 -0
  86. package/dist/vehicle.d.ts +43 -0
  87. package/dist/vehicle.js +2 -0
  88. package/dist/whatsapp.cjs +3 -3
  89. package/dist/whatsapp.js +2 -2
  90. package/dist/yup.cjs +12 -8
  91. package/dist/yup.d.cts +2 -0
  92. package/dist/yup.d.ts +2 -0
  93. package/dist/yup.js +11 -7
  94. package/dist/zod.cjs +12 -8
  95. package/dist/zod.d.cts +2 -0
  96. package/dist/zod.d.ts +2 -0
  97. package/dist/zod.js +11 -7
  98. package/package.json +101 -3
  99. package/dist/chunk-34CJGJ67.cjs +0 -1697
  100. package/dist/chunk-4VVFS6FN.cjs +0 -715
  101. package/dist/chunk-E6DT2DWQ.js +0 -1689
  102. package/dist/chunk-GJENL6VK.cjs +0 -22
  103. package/dist/chunk-LIYNKIKS.js +0 -709
@@ -1,4 +1,4 @@
1
- import { lazy, stripSeparators, toAsciiDigits } from './chunk-ENQ7O7VW.js';
1
+ import { stripSeparators, toAsciiDigits, lazy } from './chunk-ENQ7O7VW.js';
2
2
 
3
3
  // data/networks.json
4
4
  var networks_default = [
@@ -58,7 +58,7 @@ var networks_default = [
58
58
  ];
59
59
 
60
60
  // src/internal/phone-utils.ts
61
- var allocatedPrefixes = lazy(
61
+ var allocatedPrefixes = /* @__PURE__ */ lazy(
62
62
  () => new Set(
63
63
  networks_default.map((entry) => entry.prefix)
64
64
  )
@@ -0,0 +1,22 @@
1
+ import { toAsciiDigits } from './chunk-ENQ7O7VW.js';
2
+
3
+ // src/vehicle.ts
4
+ var PLATE = /^([A-Z]{1,4})[-‐‑‒–— ]?(\d{1,4})(?:[-‐‑‒–— /]{1,3}(\d{2}))?$/;
5
+ function parseVehiclePlate(plate) {
6
+ const match = PLATE.exec(toAsciiDigits(plate.trim()).toUpperCase());
7
+ if (!match) {
8
+ return null;
9
+ }
10
+ const [, series, number, year] = match;
11
+ return {
12
+ series,
13
+ number,
14
+ year: year ?? null,
15
+ formatted: `${series}-${number}`
16
+ };
17
+ }
18
+ function validateVehiclePlate(plate) {
19
+ return parseVehiclePlate(plate) !== null;
20
+ }
21
+
22
+ export { parseVehiclePlate, validateVehiclePlate };
@@ -1,5 +1,5 @@
1
- import { getNetwork } from './chunk-AZV45DMG.js';
2
- import { normalizePhoneDigits } from './chunk-6IPPANNX.js';
1
+ import { getNetwork } from './chunk-V2XE3NCG.js';
2
+ import { normalizePhoneDigits } from './chunk-P7LVE2TF.js';
3
3
 
4
4
  // src/phone.ts
5
5
  function validatePhone(phone) {
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ var chunkVPBMIYO2_cjs = require('./chunk-VPBMIYO2.cjs');
4
+
5
+ // src/vehicle.ts
6
+ var PLATE = /^([A-Z]{1,4})[-‐‑‒–— ]?(\d{1,4})(?:[-‐‑‒–— /]{1,3}(\d{2}))?$/;
7
+ function parseVehiclePlate(plate) {
8
+ const match = PLATE.exec(chunkVPBMIYO2_cjs.toAsciiDigits(plate.trim()).toUpperCase());
9
+ if (!match) {
10
+ return null;
11
+ }
12
+ const [, series, number, year] = match;
13
+ return {
14
+ series,
15
+ number,
16
+ year: year ?? null,
17
+ formatted: `${series}-${number}`
18
+ };
19
+ }
20
+ function validateVehiclePlate(plate) {
21
+ return parseVehiclePlate(plate) !== null;
22
+ }
23
+
24
+ exports.parseVehiclePlate = parseVehiclePlate;
25
+ exports.validateVehiclePlate = validateVehiclePlate;
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ var chunkSQIHFEXI_cjs = require('./chunk-SQIHFEXI.cjs');
4
+ var chunkAUQFA7EE_cjs = require('./chunk-AUQFA7EE.cjs');
5
+ var chunk7E7L3NYS_cjs = require('./chunk-7E7L3NYS.cjs');
6
+ var chunkESKXG7Y6_cjs = require('./chunk-ESKXG7Y6.cjs');
7
+ var chunkH6M6L26S_cjs = require('./chunk-H6M6L26S.cjs');
8
+ var chunkHTCSHHOR_cjs = require('./chunk-HTCSHHOR.cjs');
9
+ var chunkDHOP7LQX_cjs = require('./chunk-DHOP7LQX.cjs');
10
+
11
+ // src/adapters/rules.ts
12
+ var RULES = {
13
+ cnic: { test: chunkHTCSHHOR_cjs.validateCNIC, message: "Invalid CNIC number" },
14
+ phone: { test: chunkESKXG7Y6_cjs.validatePhone, message: "Invalid Pakistani mobile number" },
15
+ iban: { test: chunkDHOP7LQX_cjs.validateIBAN, message: "Invalid Pakistani IBAN" },
16
+ ntn: { test: chunkH6M6L26S_cjs.validateNTN, message: "Invalid NTN" },
17
+ strn: { test: chunkH6M6L26S_cjs.validateSTRN, message: "Invalid STRN" },
18
+ landline: {
19
+ test: chunkAUQFA7EE_cjs.validateLandline,
20
+ message: "Invalid Pakistani landline number"
21
+ },
22
+ passport: {
23
+ test: chunk7E7L3NYS_cjs.validatePassport,
24
+ message: "Invalid Pakistani passport number"
25
+ },
26
+ vehiclePlate: {
27
+ test: chunkSQIHFEXI_cjs.validateVehiclePlate,
28
+ message: "Invalid vehicle registration number"
29
+ }
30
+ };
31
+
32
+ exports.RULES = RULES;
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkNTD4JLDW_cjs = require('./chunk-NTD4JLDW.cjs');
3
+ var chunkYTLE5K7G_cjs = require('./chunk-YTLE5K7G.cjs');
4
4
 
5
5
  // src/whatsapp.ts
6
6
  function createWhatsAppLink(phone, message) {
7
- const digits = chunkNTD4JLDW_cjs.normalizePhoneDigits(phone);
7
+ const digits = chunkYTLE5K7G_cjs.normalizePhoneDigits(phone);
8
8
  if (digits === null) {
9
9
  return null;
10
10
  }
@@ -1,15 +1,15 @@
1
- import { getCityByPostalCode } from './chunk-LIYNKIKS.js';
2
- import { cities_default, districts_default, getProvince, getDistrictProvince } from './chunk-E6DT2DWQ.js';
3
- import { lazy, normalizeWhitespace, normalizeKey } from './chunk-ENQ7O7VW.js';
1
+ import { getCityByPostalCode } from './chunk-33QMFE2Z.js';
2
+ import { getProvince, getDistrictProvince, cities_default, districts_default } from './chunk-N4S22XX3.js';
3
+ import { normalizeWhitespace, normalizeKey, lazy } from './chunk-ENQ7O7VW.js';
4
4
 
5
5
  // src/address.ts
6
6
  function byLengthDesc(a, b) {
7
7
  return b.length - a.length;
8
8
  }
9
- var cityNames = lazy(
9
+ var cityNames = /* @__PURE__ */ lazy(
10
10
  () => cities_default.map((entry) => entry.city).sort(byLengthDesc)
11
11
  );
12
- var districtNames = lazy(
12
+ var districtNames = /* @__PURE__ */ lazy(
13
13
  () => districts_default.map((entry) => entry.district).sort(byLengthDesc)
14
14
  );
15
15
  var PROVINCES = [
@@ -1,8 +1,8 @@
1
- import { networks_default, getPhonePrefix } from './chunk-6IPPANNX.js';
1
+ import { getPhonePrefix, networks_default } from './chunk-P7LVE2TF.js';
2
2
  import { lazy } from './chunk-ENQ7O7VW.js';
3
3
 
4
4
  // src/networks.ts
5
- var prefixMap = lazy(
5
+ var prefixMap = /* @__PURE__ */ lazy(
6
6
  () => new Map(
7
7
  networks_default.map((entry) => [
8
8
  entry.prefix,
@@ -60,7 +60,7 @@ var networks_default = [
60
60
  ];
61
61
 
62
62
  // src/internal/phone-utils.ts
63
- var allocatedPrefixes = chunkVPBMIYO2_cjs.lazy(
63
+ var allocatedPrefixes = /* @__PURE__ */ chunkVPBMIYO2_cjs.lazy(
64
64
  () => new Set(
65
65
  networks_default.map((entry) => entry.prefix)
66
66
  )
@@ -1,8 +1,10 @@
1
- import { validateLandline } from './chunk-RXNYY5K5.js';
2
- import { validatePhone } from './chunk-PLDVGOKZ.js';
1
+ import { validateVehiclePlate } from './chunk-RZQJAZKC.js';
2
+ import { validateLandline } from './chunk-LQHM3ADX.js';
3
+ import { validatePassport } from './chunk-E6HSKRAE.js';
4
+ import { validatePhone } from './chunk-S274QFFB.js';
3
5
  import { validateSTRN, validateNTN } from './chunk-CEPNSHIC.js';
4
6
  import { validateCNIC } from './chunk-EEVNLTB4.js';
5
- import { validateIBAN } from './chunk-YPPKY5XZ.js';
7
+ import { validateIBAN } from './chunk-IBZPJS4H.js';
6
8
 
7
9
  // src/adapters/rules.ts
8
10
  var RULES = {
@@ -14,6 +16,14 @@ var RULES = {
14
16
  landline: {
15
17
  test: validateLandline,
16
18
  message: "Invalid Pakistani landline number"
19
+ },
20
+ passport: {
21
+ test: validatePassport,
22
+ message: "Invalid Pakistani passport number"
23
+ },
24
+ vehiclePlate: {
25
+ test: validateVehiclePlate,
26
+ message: "Invalid vehicle registration number"
17
27
  }
18
28
  };
19
29
 
@@ -1,4 +1,4 @@
1
- import { normalizePhoneDigits } from './chunk-6IPPANNX.js';
1
+ import { normalizePhoneDigits } from './chunk-P7LVE2TF.js';
2
2
 
3
3
  // src/whatsapp.ts
4
4
  function createWhatsAppLink(phone, message) {
@@ -0,0 +1,57 @@
1
+ 'use strict';
2
+
3
+ var chunkTBTWZC74_cjs = require('./chunk-TBTWZC74.cjs');
4
+ require('./chunk-SQIHFEXI.cjs');
5
+ require('./chunk-AUQFA7EE.cjs');
6
+ require('./chunk-7E7L3NYS.cjs');
7
+ require('./chunk-ESKXG7Y6.cjs');
8
+ require('./chunk-MTS6SVNP.cjs');
9
+ require('./chunk-YTLE5K7G.cjs');
10
+ require('./chunk-H6M6L26S.cjs');
11
+ require('./chunk-HTCSHHOR.cjs');
12
+ require('./chunk-DHOP7LQX.cjs');
13
+ require('./chunk-VPBMIYO2.cjs');
14
+ var classValidator = require('class-validator');
15
+
16
+ function decorator(name) {
17
+ const rule = chunkTBTWZC74_cjs.RULES[name];
18
+ return (options = {}) => (target, propertyName) => {
19
+ classValidator.registerDecorator({
20
+ name: `pk-${name}`,
21
+ target: target.constructor,
22
+ propertyName,
23
+ options: { ...options, message: options.message ?? rule.message },
24
+ validator: {
25
+ validate: (value) => typeof value === "string" && rule.test(value)
26
+ }
27
+ });
28
+ };
29
+ }
30
+ var pk = {
31
+ cnic: decorator("cnic"),
32
+ phone: decorator("phone"),
33
+ iban: decorator("iban"),
34
+ ntn: decorator("ntn"),
35
+ strn: decorator("strn"),
36
+ landline: decorator("landline"),
37
+ passport: decorator("passport"),
38
+ vehiclePlate: decorator("vehiclePlate")
39
+ };
40
+ var IsCNIC = pk.cnic;
41
+ var IsPakPhone = pk.phone;
42
+ var IsPakIBAN = pk.iban;
43
+ var IsNTN = pk.ntn;
44
+ var IsSTRN = pk.strn;
45
+ var IsPakLandline = pk.landline;
46
+ var IsPakPassport = pk.passport;
47
+ var IsVehiclePlate = pk.vehiclePlate;
48
+
49
+ exports.IsCNIC = IsCNIC;
50
+ exports.IsNTN = IsNTN;
51
+ exports.IsPakIBAN = IsPakIBAN;
52
+ exports.IsPakLandline = IsPakLandline;
53
+ exports.IsPakPassport = IsPakPassport;
54
+ exports.IsPakPhone = IsPakPhone;
55
+ exports.IsSTRN = IsSTRN;
56
+ exports.IsVehiclePlate = IsVehiclePlate;
57
+ exports.pk = pk;
@@ -0,0 +1,57 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+
3
+ /**
4
+ * Options for the decorators: class-validator's own options (`groups`,
5
+ * `each`, `always`, `context`), plus a custom `message`.
6
+ */
7
+ type DecoratorOptions = ValidationOptions;
8
+ /**
9
+ * class-validator decorators for Pakistani identifiers. They work in NestJS
10
+ * DTOs with the built-in `ValidationPipe`; no NestJS package is needed.
11
+ * Combine with `@IsOptional()` for optional fields.
12
+ *
13
+ * @example
14
+ * import { IsOptional } from 'class-validator';
15
+ * import { IsCNIC, IsPakPhone } from 'pakdatakit/class-validator';
16
+ *
17
+ * class CreateCustomerDto {
18
+ * @IsCNIC()
19
+ * cnic!: string;
20
+ *
21
+ * @IsOptional()
22
+ * @IsPakPhone({ message: 'Enter a Pakistani mobile number' })
23
+ * phone?: string;
24
+ * }
25
+ */
26
+ declare const pk: {
27
+ cnic: (options?: DecoratorOptions) => PropertyDecorator;
28
+ phone: (options?: DecoratorOptions) => PropertyDecorator;
29
+ iban: (options?: DecoratorOptions) => PropertyDecorator;
30
+ ntn: (options?: DecoratorOptions) => PropertyDecorator;
31
+ strn: (options?: DecoratorOptions) => PropertyDecorator;
32
+ landline: (options?: DecoratorOptions) => PropertyDecorator;
33
+ passport: (options?: DecoratorOptions) => PropertyDecorator;
34
+ vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
35
+ };
36
+ /** Validates a CNIC. See {@link pk}. */
37
+ declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
38
+ /** Validates a Pakistani mobile number. See {@link pk}. */
39
+ declare const IsPakPhone: (options?: DecoratorOptions) => PropertyDecorator;
40
+ /**
41
+ * Validates a Pakistani IBAN. Named `IsPakIBAN` so it does not clash with
42
+ * class-validator's own `IsIBAN`. See {@link pk}.
43
+ */
44
+ declare const IsPakIBAN: (options?: DecoratorOptions) => PropertyDecorator;
45
+ /** Validates an NTN. See {@link pk}. */
46
+ declare const IsNTN: (options?: DecoratorOptions) => PropertyDecorator;
47
+ /** Validates an STRN. See {@link pk}. */
48
+ declare const IsSTRN: (options?: DecoratorOptions) => PropertyDecorator;
49
+ /** Validates a Pakistani landline number. See {@link pk}. */
50
+ declare const IsPakLandline: (options?: DecoratorOptions) => PropertyDecorator;
51
+ /** Validates the format of a Pakistani passport number. See {@link pk}. */
52
+ declare const IsPakPassport: (options?: DecoratorOptions) => PropertyDecorator;
53
+ /** Validates the format of a vehicle registration number. See {@link pk}. */
54
+ declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
55
+
56
+ export { IsCNIC, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
57
+ export type { DecoratorOptions };
@@ -0,0 +1,57 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+
3
+ /**
4
+ * Options for the decorators: class-validator's own options (`groups`,
5
+ * `each`, `always`, `context`), plus a custom `message`.
6
+ */
7
+ type DecoratorOptions = ValidationOptions;
8
+ /**
9
+ * class-validator decorators for Pakistani identifiers. They work in NestJS
10
+ * DTOs with the built-in `ValidationPipe`; no NestJS package is needed.
11
+ * Combine with `@IsOptional()` for optional fields.
12
+ *
13
+ * @example
14
+ * import { IsOptional } from 'class-validator';
15
+ * import { IsCNIC, IsPakPhone } from 'pakdatakit/class-validator';
16
+ *
17
+ * class CreateCustomerDto {
18
+ * @IsCNIC()
19
+ * cnic!: string;
20
+ *
21
+ * @IsOptional()
22
+ * @IsPakPhone({ message: 'Enter a Pakistani mobile number' })
23
+ * phone?: string;
24
+ * }
25
+ */
26
+ declare const pk: {
27
+ cnic: (options?: DecoratorOptions) => PropertyDecorator;
28
+ phone: (options?: DecoratorOptions) => PropertyDecorator;
29
+ iban: (options?: DecoratorOptions) => PropertyDecorator;
30
+ ntn: (options?: DecoratorOptions) => PropertyDecorator;
31
+ strn: (options?: DecoratorOptions) => PropertyDecorator;
32
+ landline: (options?: DecoratorOptions) => PropertyDecorator;
33
+ passport: (options?: DecoratorOptions) => PropertyDecorator;
34
+ vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
35
+ };
36
+ /** Validates a CNIC. See {@link pk}. */
37
+ declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
38
+ /** Validates a Pakistani mobile number. See {@link pk}. */
39
+ declare const IsPakPhone: (options?: DecoratorOptions) => PropertyDecorator;
40
+ /**
41
+ * Validates a Pakistani IBAN. Named `IsPakIBAN` so it does not clash with
42
+ * class-validator's own `IsIBAN`. See {@link pk}.
43
+ */
44
+ declare const IsPakIBAN: (options?: DecoratorOptions) => PropertyDecorator;
45
+ /** Validates an NTN. See {@link pk}. */
46
+ declare const IsNTN: (options?: DecoratorOptions) => PropertyDecorator;
47
+ /** Validates an STRN. See {@link pk}. */
48
+ declare const IsSTRN: (options?: DecoratorOptions) => PropertyDecorator;
49
+ /** Validates a Pakistani landline number. See {@link pk}. */
50
+ declare const IsPakLandline: (options?: DecoratorOptions) => PropertyDecorator;
51
+ /** Validates the format of a Pakistani passport number. See {@link pk}. */
52
+ declare const IsPakPassport: (options?: DecoratorOptions) => PropertyDecorator;
53
+ /** Validates the format of a vehicle registration number. See {@link pk}. */
54
+ declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
55
+
56
+ export { IsCNIC, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
57
+ export type { DecoratorOptions };
@@ -0,0 +1,47 @@
1
+ import { RULES } from './chunk-YTSMFGTW.js';
2
+ import './chunk-RZQJAZKC.js';
3
+ import './chunk-LQHM3ADX.js';
4
+ import './chunk-E6HSKRAE.js';
5
+ import './chunk-S274QFFB.js';
6
+ import './chunk-V2XE3NCG.js';
7
+ import './chunk-P7LVE2TF.js';
8
+ import './chunk-CEPNSHIC.js';
9
+ import './chunk-EEVNLTB4.js';
10
+ import './chunk-IBZPJS4H.js';
11
+ import './chunk-ENQ7O7VW.js';
12
+ import { registerDecorator } from 'class-validator';
13
+
14
+ function decorator(name) {
15
+ const rule = RULES[name];
16
+ return (options = {}) => (target, propertyName) => {
17
+ registerDecorator({
18
+ name: `pk-${name}`,
19
+ target: target.constructor,
20
+ propertyName,
21
+ options: { ...options, message: options.message ?? rule.message },
22
+ validator: {
23
+ validate: (value) => typeof value === "string" && rule.test(value)
24
+ }
25
+ });
26
+ };
27
+ }
28
+ var pk = {
29
+ cnic: decorator("cnic"),
30
+ phone: decorator("phone"),
31
+ iban: decorator("iban"),
32
+ ntn: decorator("ntn"),
33
+ strn: decorator("strn"),
34
+ landline: decorator("landline"),
35
+ passport: decorator("passport"),
36
+ vehiclePlate: decorator("vehiclePlate")
37
+ };
38
+ var IsCNIC = pk.cnic;
39
+ var IsPakPhone = pk.phone;
40
+ var IsPakIBAN = pk.iban;
41
+ var IsNTN = pk.ntn;
42
+ var IsSTRN = pk.strn;
43
+ var IsPakLandline = pk.landline;
44
+ var IsPakPassport = pk.passport;
45
+ var IsVehiclePlate = pk.vehiclePlate;
46
+
47
+ export { IsCNIC, IsNTN, 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.2.1";
5
+ var version = "2.3.0";
6
6
  var EXIT_OK = 0;
7
7
  var EXIT_NEGATIVE = 1;
8
8
  var EXIT_USAGE = 2;
package/dist/geo.cjs CHANGED
@@ -1,27 +1,43 @@
1
1
  'use strict';
2
2
 
3
- var chunk34CJGJ67_cjs = require('./chunk-34CJGJ67.cjs');
3
+ var chunkOKMBYX3F_cjs = require('./chunk-OKMBYX3F.cjs');
4
4
  require('./chunk-VPBMIYO2.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "getDistrictProvince", {
9
9
  enumerable: true,
10
- get: function () { return chunk34CJGJ67_cjs.getDistrictProvince; }
10
+ get: function () { return chunkOKMBYX3F_cjs.getDistrictProvince; }
11
11
  });
12
12
  Object.defineProperty(exports, "getDistrictsByProvince", {
13
13
  enumerable: true,
14
- get: function () { return chunk34CJGJ67_cjs.getDistrictsByProvince; }
14
+ get: function () { return chunkOKMBYX3F_cjs.getDistrictsByProvince; }
15
+ });
16
+ Object.defineProperty(exports, "getDivisionOfDistrict", {
17
+ enumerable: true,
18
+ get: function () { return chunkOKMBYX3F_cjs.getDivisionOfDistrict; }
19
+ });
20
+ Object.defineProperty(exports, "getDivisions", {
21
+ enumerable: true,
22
+ get: function () { return chunkOKMBYX3F_cjs.getDivisions; }
15
23
  });
16
24
  Object.defineProperty(exports, "getProvince", {
17
25
  enumerable: true,
18
- get: function () { return chunk34CJGJ67_cjs.getProvince; }
26
+ get: function () { return chunkOKMBYX3F_cjs.getProvince; }
27
+ });
28
+ Object.defineProperty(exports, "getTehsilDistrict", {
29
+ enumerable: true,
30
+ get: function () { return chunkOKMBYX3F_cjs.getTehsilDistrict; }
31
+ });
32
+ Object.defineProperty(exports, "getTehsils", {
33
+ enumerable: true,
34
+ get: function () { return chunkOKMBYX3F_cjs.getTehsils; }
19
35
  });
20
36
  Object.defineProperty(exports, "searchCities", {
21
37
  enumerable: true,
22
- get: function () { return chunk34CJGJ67_cjs.searchCities; }
38
+ get: function () { return chunkOKMBYX3F_cjs.searchCities; }
23
39
  });
24
40
  Object.defineProperty(exports, "searchDistricts", {
25
41
  enumerable: true,
26
- get: function () { return chunk34CJGJ67_cjs.searchDistricts; }
42
+ get: function () { return chunkOKMBYX3F_cjs.searchDistricts; }
27
43
  });
package/dist/geo.d.cts CHANGED
@@ -39,5 +39,60 @@ declare function searchDistricts(query: string): string[];
39
39
  * @returns Alphabetically sorted district names
40
40
  */
41
41
  declare function getDistrictsByProvince(province: string): string[];
42
+ /**
43
+ * Returns the administrative divisions of Pakistan, or of one province.
44
+ *
45
+ * The list is the 30 divisions of the 2023 census: Punjab 9, Sindh 6, Khyber
46
+ * Pakhtunkhwa 7 and Balochistan 8. Islamabad has no division, and the census
47
+ * tables do not cover Azad Jammu and Kashmir or Gilgit-Baltistan. Divisions
48
+ * created since the census (such as Gujrat in Punjab) are not included.
49
+ *
50
+ * @param province - Optional province name (case-insensitive)
51
+ * @returns Alphabetically sorted division names
52
+ */
53
+ declare function getDivisions(province?: string): string[];
54
+ /**
55
+ * Returns the division a district belonged to in the 2023 census.
56
+ *
57
+ * Census-district caveat: only the 136 districts of the 2023 census have a
58
+ * division here, under the name they had then (so `Quetta`, `Dera Bugti` and
59
+ * `South Waziristan` work, and their successors do not). Districts created
60
+ * after the census, and those of Azad Jammu and Kashmir, Gilgit-Baltistan and
61
+ * Islamabad, return `null`.
62
+ *
63
+ * @param district - District name (case-insensitive)
64
+ * @returns Division name or `null` if not known
65
+ */
66
+ declare function getDivisionOfDistrict(district: string): string | null;
67
+ /**
68
+ * Returns the tehsils (talukas, sub-divisions) of a district.
69
+ *
70
+ * Census-district caveat: the data is the 591 tehsil-level units of the 2023
71
+ * census, each recorded under the district it was in then. For a district of
72
+ * the 2023 census this returns its census tehsils, even if some have since
73
+ * moved to a new district (so `Rawalpindi` still lists Murree). For a
74
+ * district created after the census it returns only the tehsils an official
75
+ * source places in it, which can be an empty list. Azad Jammu and Kashmir
76
+ * and Gilgit-Baltistan are not covered.
77
+ *
78
+ * @param district - District name (case-insensitive); former names such as
79
+ * `Quetta` and `South Waziristan` work
80
+ * @returns Alphabetically sorted tehsil names
81
+ */
82
+ declare function getTehsils(district: string): string[];
83
+ /**
84
+ * Returns the district a tehsil was in at the 2023 census.
85
+ *
86
+ * Census-district caveat: the result is the census district, which may have
87
+ * been split since (a tehsil of `Quetta` is now in Quetta East or Quetta
88
+ * West). A few names are shared by tehsils in different districts (`Saddar`,
89
+ * `Sahiwal`, `Khanpur`); pass the province to tell them apart. Returns
90
+ * `null` when the name is unknown or still matches more than one district.
91
+ *
92
+ * @param tehsil - Tehsil, taluka or sub-division name (case-insensitive)
93
+ * @param province - Optional province to narrow the search
94
+ * @returns District name or `null`
95
+ */
96
+ declare function getTehsilDistrict(tehsil: string, province?: string): string | null;
42
97
 
43
- export { getDistrictProvince, getDistrictsByProvince, getProvince, searchCities, searchDistricts };
98
+ export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts };
package/dist/geo.d.ts CHANGED
@@ -39,5 +39,60 @@ declare function searchDistricts(query: string): string[];
39
39
  * @returns Alphabetically sorted district names
40
40
  */
41
41
  declare function getDistrictsByProvince(province: string): string[];
42
+ /**
43
+ * Returns the administrative divisions of Pakistan, or of one province.
44
+ *
45
+ * The list is the 30 divisions of the 2023 census: Punjab 9, Sindh 6, Khyber
46
+ * Pakhtunkhwa 7 and Balochistan 8. Islamabad has no division, and the census
47
+ * tables do not cover Azad Jammu and Kashmir or Gilgit-Baltistan. Divisions
48
+ * created since the census (such as Gujrat in Punjab) are not included.
49
+ *
50
+ * @param province - Optional province name (case-insensitive)
51
+ * @returns Alphabetically sorted division names
52
+ */
53
+ declare function getDivisions(province?: string): string[];
54
+ /**
55
+ * Returns the division a district belonged to in the 2023 census.
56
+ *
57
+ * Census-district caveat: only the 136 districts of the 2023 census have a
58
+ * division here, under the name they had then (so `Quetta`, `Dera Bugti` and
59
+ * `South Waziristan` work, and their successors do not). Districts created
60
+ * after the census, and those of Azad Jammu and Kashmir, Gilgit-Baltistan and
61
+ * Islamabad, return `null`.
62
+ *
63
+ * @param district - District name (case-insensitive)
64
+ * @returns Division name or `null` if not known
65
+ */
66
+ declare function getDivisionOfDistrict(district: string): string | null;
67
+ /**
68
+ * Returns the tehsils (talukas, sub-divisions) of a district.
69
+ *
70
+ * Census-district caveat: the data is the 591 tehsil-level units of the 2023
71
+ * census, each recorded under the district it was in then. For a district of
72
+ * the 2023 census this returns its census tehsils, even if some have since
73
+ * moved to a new district (so `Rawalpindi` still lists Murree). For a
74
+ * district created after the census it returns only the tehsils an official
75
+ * source places in it, which can be an empty list. Azad Jammu and Kashmir
76
+ * and Gilgit-Baltistan are not covered.
77
+ *
78
+ * @param district - District name (case-insensitive); former names such as
79
+ * `Quetta` and `South Waziristan` work
80
+ * @returns Alphabetically sorted tehsil names
81
+ */
82
+ declare function getTehsils(district: string): string[];
83
+ /**
84
+ * Returns the district a tehsil was in at the 2023 census.
85
+ *
86
+ * Census-district caveat: the result is the census district, which may have
87
+ * been split since (a tehsil of `Quetta` is now in Quetta East or Quetta
88
+ * West). A few names are shared by tehsils in different districts (`Saddar`,
89
+ * `Sahiwal`, `Khanpur`); pass the province to tell them apart. Returns
90
+ * `null` when the name is unknown or still matches more than one district.
91
+ *
92
+ * @param tehsil - Tehsil, taluka or sub-division name (case-insensitive)
93
+ * @param province - Optional province to narrow the search
94
+ * @returns District name or `null`
95
+ */
96
+ declare function getTehsilDistrict(tehsil: string, province?: string): string | null;
42
97
 
43
- export { getDistrictProvince, getDistrictsByProvince, getProvince, searchCities, searchDistricts };
98
+ export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts };
package/dist/geo.js CHANGED
@@ -1,2 +1,2 @@
1
- export { getDistrictProvince, getDistrictsByProvince, getProvince, searchCities, searchDistricts } from './chunk-E6DT2DWQ.js';
1
+ export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts } from './chunk-N4S22XX3.js';
2
2
  import './chunk-ENQ7O7VW.js';
package/dist/holidays.cjs CHANGED
@@ -1,19 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var chunkXCXFGTHW_cjs = require('./chunk-XCXFGTHW.cjs');
3
+ var chunkJ5ZF46NZ_cjs = require('./chunk-J5ZF46NZ.cjs');
4
4
  require('./chunk-CYJJ7KGC.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "getHolidaysOn", {
9
9
  enumerable: true,
10
- get: function () { return chunkXCXFGTHW_cjs.getHolidaysOn; }
10
+ get: function () { return chunkJ5ZF46NZ_cjs.getHolidaysOn; }
11
11
  });
12
12
  Object.defineProperty(exports, "getPakistanHolidays", {
13
13
  enumerable: true,
14
- get: function () { return chunkXCXFGTHW_cjs.getPakistanHolidays; }
14
+ get: function () { return chunkJ5ZF46NZ_cjs.getPakistanHolidays; }
15
15
  });
16
16
  Object.defineProperty(exports, "isPakistanHoliday", {
17
17
  enumerable: true,
18
- get: function () { return chunkXCXFGTHW_cjs.isPakistanHoliday; }
18
+ get: function () { return chunkJ5ZF46NZ_cjs.isPakistanHoliday; }
19
19
  });
package/dist/holidays.js CHANGED
@@ -1,2 +1,2 @@
1
- export { getHolidaysOn, getPakistanHolidays, isPakistanHoliday } from './chunk-HBOZIITD.js';
1
+ export { getHolidaysOn, getPakistanHolidays, isPakistanHoliday } from './chunk-CADQM4ZN.js';
2
2
  import './chunk-Z5JEIQVW.js';