pakdatakit 2.5.0 → 2.6.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.
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ // src/format.ts
4
+ var LAKH = 1e5;
5
+ var CRORE = 1e7;
6
+ var pkrFormatter = new Intl.NumberFormat("en-PK", {
7
+ maximumFractionDigits: 0
8
+ });
9
+ function assertFinite(amount) {
10
+ if (typeof amount !== "number" || !Number.isFinite(amount)) {
11
+ throw new RangeError(
12
+ `Amount must be a finite number, received ${String(amount)}`
13
+ );
14
+ }
15
+ }
16
+ function roundTo2(value) {
17
+ return Math.round(value * 100) / 100;
18
+ }
19
+ function formatPKR(amount) {
20
+ assertFinite(amount);
21
+ const rounded = Math.round(Math.abs(amount));
22
+ const sign = amount < 0 && rounded !== 0 ? "-" : "";
23
+ return `${sign}Rs. ${pkrFormatter.format(rounded)}`;
24
+ }
25
+ function formatLakh(amount) {
26
+ assertFinite(amount);
27
+ const sign = amount < 0 ? "-" : "";
28
+ const absolute = Math.abs(amount);
29
+ const crores = roundTo2(absolute / CRORE);
30
+ if (crores >= 1) {
31
+ return `${sign}${crores} Crore`;
32
+ }
33
+ const lakhs = roundTo2(absolute / LAKH);
34
+ if (lakhs >= 1) {
35
+ return `${sign}${lakhs} Lakh`;
36
+ }
37
+ return formatPKR(amount);
38
+ }
39
+ var SPACE = /[ \t\n\r\u00A0\u202F]/.source;
40
+ var TRIM = new RegExp(`^${SPACE}+|${SPACE}+$`, "g");
41
+ var CURRENCY = /(rs\.?|pkr|\u20A8)/.source;
42
+ var NUMBER = /(\d{1,3}(?:,\d{3})+|\d{1,2}(?:,\d{2})+,\d{3}|\d+)?(?:\.(\d*))?/.source;
43
+ var THOUSAND = /k|thousands?|hazar|\u06C1\u0632\u0627\u0631/.source;
44
+ var LAKH_UNIT = /lakhs?|lacs?|\u0644\u0627\u06A9\u06BE/.source;
45
+ var CRORE_UNIT = /crores?|cr|\u06A9\u0631\u0648\u0691/.source;
46
+ var AMOUNT = new RegExp(
47
+ `^(?:${CURRENCY}${SPACE}*)?${NUMBER}(?:${SPACE}*(${THOUSAND}|${LAKH_UNIT}|${CRORE_UNIT}))?(?:${SPACE}*${CURRENCY})?(?:${SPACE}*(\\/-))?$`
48
+ );
49
+ function unitExponent(unit) {
50
+ if (unit === void 0) return 0;
51
+ if (new RegExp(`^(?:${THOUSAND})$`).test(unit)) return 3;
52
+ if (new RegExp(`^(?:${LAKH_UNIT})$`).test(unit)) return 5;
53
+ return 7;
54
+ }
55
+ var MAX_PAISA = 5000000000000000n;
56
+ function parseAmount(input) {
57
+ if (typeof input !== "string") return null;
58
+ const raw = input.replace(TRIM, "");
59
+ const text = raw.replace(/[\u06F0-\u06F9]/g, (d) => String(d.charCodeAt(0) - 1776)).replace(/[\u0660-\u0669]/g, (d) => String(d.charCodeAt(0) - 1632)).replace(/\u066B/g, ".").replace(/\u066C/g, ",").replace(/[A-Z]/g, (c) => c.toLowerCase());
60
+ const match = AMOUNT.exec(text);
61
+ if (!match) return null;
62
+ const [, before, whole = "", fraction, unit, after] = match;
63
+ if (before !== void 0 && after !== void 0) return null;
64
+ if (whole === "" && (fraction === void 0 || fraction === "")) return null;
65
+ const digits = whole.replace(/,/g, "") + (fraction ?? "");
66
+ const point = whole.replace(/,/g, "").length + unitExponent(unit);
67
+ const padded = digits.padEnd(point + 3, "0");
68
+ const rupees = padded.slice(0, point) || "0";
69
+ const paisa = padded.slice(point, point + 2);
70
+ let cents = BigInt(rupees + paisa);
71
+ if (padded.charCodeAt(point + 2) >= 53) cents += 1n;
72
+ if (cents > MAX_PAISA) return null;
73
+ return { value: Number(cents) / 100, raw };
74
+ }
75
+ function formatAmountInput(input) {
76
+ const parsed = parseAmount(input);
77
+ if (parsed === null) return null;
78
+ const cents = Math.round(parsed.value * 100);
79
+ const rupees = String(Math.floor(cents / 100)).replace(
80
+ /\B(?=(\d{3})+(?!\d))/g,
81
+ ","
82
+ );
83
+ const paisa = cents % 100;
84
+ return `Rs. ${rupees}${paisa ? `.${String(paisa).padStart(2, "0")}` : ""}`;
85
+ }
86
+
87
+ exports.formatAmountInput = formatAmountInput;
88
+ exports.formatLakh = formatLakh;
89
+ exports.formatPKR = formatPKR;
90
+ exports.parseAmount = parseAmount;
@@ -6,6 +6,7 @@ import { validateIBAN } from './chunk-IBZPJS4H.js';
6
6
  import { validateLandline } from './chunk-LQHM3ADX.js';
7
7
  import { validatePassport } from './chunk-E6HSKRAE.js';
8
8
  import { validateCNIC } from './chunk-EEVNLTB4.js';
9
+ import { parseAmount } from './chunk-NDW52ZK3.js';
9
10
 
10
11
  // src/adapters/rules.ts
11
12
  var RULES = {
@@ -29,6 +30,10 @@ var RULES = {
29
30
  codPhone: {
30
31
  test: (value) => phoneRiskSignals(value).length === 0,
31
32
  message: "Enter a mobile number a courier can call"
33
+ },
34
+ amount: {
35
+ test: (value) => parseAmount(value) !== null,
36
+ message: "Enter an amount in rupees, like 150,000 or 1.5 lakh"
32
37
  }
33
38
  };
34
39
 
@@ -8,6 +8,7 @@ var chunkDHOP7LQX_cjs = require('./chunk-DHOP7LQX.cjs');
8
8
  var chunkAUQFA7EE_cjs = require('./chunk-AUQFA7EE.cjs');
9
9
  var chunk7E7L3NYS_cjs = require('./chunk-7E7L3NYS.cjs');
10
10
  var chunkHTCSHHOR_cjs = require('./chunk-HTCSHHOR.cjs');
11
+ var chunkNLSIAPZG_cjs = require('./chunk-NLSIAPZG.cjs');
11
12
 
12
13
  // src/adapters/rules.ts
13
14
  var RULES = {
@@ -31,6 +32,10 @@ var RULES = {
31
32
  codPhone: {
32
33
  test: (value) => chunkYDUXIENX_cjs.phoneRiskSignals(value).length === 0,
33
34
  message: "Enter a mobile number a courier can call"
35
+ },
36
+ amount: {
37
+ test: (value) => chunkNLSIAPZG_cjs.parseAmount(value) !== null,
38
+ message: "Enter an amount in rupees, like 150,000 or 1.5 lakh"
34
39
  }
35
40
  };
36
41
 
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkXCFZKCV2_cjs = require('./chunk-XCFZKCV2.cjs');
3
+ var chunkYSRYWZCQ_cjs = require('./chunk-YSRYWZCQ.cjs');
4
4
  require('./chunk-ESKXG7Y6.cjs');
5
5
  require('./chunk-YDUXIENX.cjs');
6
6
  require('./chunk-H6M6L26S.cjs');
@@ -13,13 +13,14 @@ require('./chunk-7E7L3NYS.cjs');
13
13
  require('./chunk-QFPEFD67.cjs');
14
14
  require('./chunk-I7UUPD3G.cjs');
15
15
  require('./chunk-HTCSHHOR.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 = chunkXCFZKCV2_cjs.RULES[name];
23
+ const rule = chunkYSRYWZCQ_cjs.RULES[name];
23
24
  return (options = {}) => (target, propertyName) => {
24
25
  classValidator.registerDecorator({
25
26
  name: `pk-${name}`,
@@ -41,7 +42,8 @@ var pk = {
41
42
  landline: decorator("landline"),
42
43
  passport: decorator("passport"),
43
44
  vehiclePlate: decorator("vehiclePlate"),
44
- codPhone: decorator("codPhone")
45
+ codPhone: decorator("codPhone"),
46
+ amount: decorator("amount")
45
47
  };
46
48
  var IsCNIC = pk.cnic;
47
49
  var IsPakPhone = pk.phone;
@@ -52,10 +54,12 @@ var IsPakLandline = pk.landline;
52
54
  var IsPakPassport = pk.passport;
53
55
  var IsVehiclePlate = pk.vehiclePlate;
54
56
  var IsCodPhone = pk.codPhone;
57
+ var IsPakAmount = pk.amount;
55
58
 
56
59
  exports.IsCNIC = IsCNIC;
57
60
  exports.IsCodPhone = IsCodPhone;
58
61
  exports.IsNTN = IsNTN;
62
+ exports.IsPakAmount = IsPakAmount;
59
63
  exports.IsPakIBAN = IsPakIBAN;
60
64
  exports.IsPakLandline = IsPakLandline;
61
65
  exports.IsPakPassport = IsPakPassport;
@@ -33,6 +33,7 @@ declare const pk: {
33
33
  passport: (options?: DecoratorOptions) => PropertyDecorator;
34
34
  vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
35
35
  codPhone: (options?: DecoratorOptions) => PropertyDecorator;
36
+ amount: (options?: DecoratorOptions) => PropertyDecorator;
36
37
  };
37
38
  /** Validates a CNIC. See {@link pk}. */
38
39
  declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
@@ -58,6 +59,11 @@ declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
58
59
  * `phoneRiskSignals` flag. See {@link pk}.
59
60
  */
60
61
  declare const IsCodPhone: (options?: DecoratorOptions) => PropertyDecorator;
62
+ /**
63
+ * Validates a rupee amount as people type it (`150,000`, `Rs. 1,50,000/-`,
64
+ * `1.5 lakh`): one that `parseAmount` reads. See {@link pk}.
65
+ */
66
+ declare const IsPakAmount: (options?: DecoratorOptions) => PropertyDecorator;
61
67
 
62
- export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
68
+ export { IsCNIC, IsCodPhone, IsNTN, IsPakAmount, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
63
69
  export type { DecoratorOptions };
@@ -33,6 +33,7 @@ declare const pk: {
33
33
  passport: (options?: DecoratorOptions) => PropertyDecorator;
34
34
  vehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
35
35
  codPhone: (options?: DecoratorOptions) => PropertyDecorator;
36
+ amount: (options?: DecoratorOptions) => PropertyDecorator;
36
37
  };
37
38
  /** Validates a CNIC. See {@link pk}. */
38
39
  declare const IsCNIC: (options?: DecoratorOptions) => PropertyDecorator;
@@ -58,6 +59,11 @@ declare const IsVehiclePlate: (options?: DecoratorOptions) => PropertyDecorator;
58
59
  * `phoneRiskSignals` flag. See {@link pk}.
59
60
  */
60
61
  declare const IsCodPhone: (options?: DecoratorOptions) => PropertyDecorator;
62
+ /**
63
+ * Validates a rupee amount as people type it (`150,000`, `Rs. 1,50,000/-`,
64
+ * `1.5 lakh`): one that `parseAmount` reads. See {@link pk}.
65
+ */
66
+ declare const IsPakAmount: (options?: DecoratorOptions) => PropertyDecorator;
61
67
 
62
- export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
68
+ export { IsCNIC, IsCodPhone, IsNTN, IsPakAmount, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
63
69
  export type { DecoratorOptions };
@@ -1,4 +1,4 @@
1
- import { RULES } from './chunk-IDTRFOQW.js';
1
+ import { RULES } from './chunk-QG5T7YQ5.js';
2
2
  import './chunk-S274QFFB.js';
3
3
  import './chunk-UYFTXD4P.js';
4
4
  import './chunk-CEPNSHIC.js';
@@ -11,6 +11,7 @@ import './chunk-E6HSKRAE.js';
11
11
  import './chunk-B7DOQ5QF.js';
12
12
  import './chunk-33QMFE2Z.js';
13
13
  import './chunk-EEVNLTB4.js';
14
+ import './chunk-NDW52ZK3.js';
14
15
  import './chunk-XOTCIXY6.js';
15
16
  import './chunk-E2XU6NOW.js';
16
17
  import './chunk-ENQ7O7VW.js';
@@ -39,7 +40,8 @@ var pk = {
39
40
  landline: decorator("landline"),
40
41
  passport: decorator("passport"),
41
42
  vehiclePlate: decorator("vehiclePlate"),
42
- codPhone: decorator("codPhone")
43
+ codPhone: decorator("codPhone"),
44
+ amount: decorator("amount")
43
45
  };
44
46
  var IsCNIC = pk.cnic;
45
47
  var IsPakPhone = pk.phone;
@@ -50,5 +52,6 @@ var IsPakLandline = pk.landline;
50
52
  var IsPakPassport = pk.passport;
51
53
  var IsVehiclePlate = pk.vehiclePlate;
52
54
  var IsCodPhone = pk.codPhone;
55
+ var IsPakAmount = pk.amount;
53
56
 
54
- export { IsCNIC, IsCodPhone, IsNTN, IsPakIBAN, IsPakLandline, IsPakPassport, IsPakPhone, IsSTRN, IsVehiclePlate, pk };
57
+ 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.0";
5
+ var version = "2.6.0";
6
6
  var EXIT_OK = 0;
7
7
  var EXIT_NEGATIVE = 1;
8
8
  var EXIT_USAGE = 2;
package/dist/format.cjs CHANGED
@@ -1,14 +1,22 @@
1
1
  'use strict';
2
2
 
3
- var chunkLVHTH4P7_cjs = require('./chunk-LVHTH4P7.cjs');
3
+ var chunkNLSIAPZG_cjs = require('./chunk-NLSIAPZG.cjs');
4
4
 
5
5
 
6
6
 
7
+ Object.defineProperty(exports, "formatAmountInput", {
8
+ enumerable: true,
9
+ get: function () { return chunkNLSIAPZG_cjs.formatAmountInput; }
10
+ });
7
11
  Object.defineProperty(exports, "formatLakh", {
8
12
  enumerable: true,
9
- get: function () { return chunkLVHTH4P7_cjs.formatLakh; }
13
+ get: function () { return chunkNLSIAPZG_cjs.formatLakh; }
10
14
  });
11
15
  Object.defineProperty(exports, "formatPKR", {
12
16
  enumerable: true,
13
- get: function () { return chunkLVHTH4P7_cjs.formatPKR; }
17
+ get: function () { return chunkNLSIAPZG_cjs.formatPKR; }
18
+ });
19
+ Object.defineProperty(exports, "parseAmount", {
20
+ enumerable: true,
21
+ get: function () { return chunkNLSIAPZG_cjs.parseAmount; }
14
22
  });
package/dist/format.d.cts CHANGED
@@ -23,5 +23,61 @@ declare function formatPKR(amount: number): string;
23
23
  * @throws {RangeError} If `amount` is `NaN` or infinite
24
24
  */
25
25
  declare function formatLakh(amount: number): string;
26
+ /** The result of {@link parseAmount}. */
27
+ interface ParsedAmount {
28
+ /** The amount in rupees, rounded half-up to the paisa (2 decimals). */
29
+ value: number;
30
+ /** The input with surrounding whitespace removed. */
31
+ raw: string;
32
+ }
33
+ /**
34
+ * Reads a rupee amount the way people type it in Pakistan, and returns it in
35
+ * rupees, rounded half-up to the paisa. Returns `null` for anything that is
36
+ * not exactly one non-negative amount; it never throws.
37
+ *
38
+ * Accepted:
39
+ * - digits, with or without grouping: `150000`, `150,000` (international) or
40
+ * `1,50,000` (Pakistani: groups of two, then three), and decimals
41
+ * (`1,234.50`, `.5`, `5.`); a grouping must be complete and consistent;
42
+ * - Urdu (`۱۵۰۰۰۰`) and Arabic-Indic (`١٥٠٠٠٠`) digits, also mixed with
43
+ * 0-9, and the Arabic decimal and thousands separators (`٫`, `٬`);
44
+ * - one currency mark before or after the number: `Rs`, `Rs.`, `PKR` or `₨`
45
+ * (any case), and a trailing `/-` (`Rs. 5,000/-`);
46
+ * - one shorthand unit after the number, with or without a space, in any
47
+ * case: `k`, `thousand(s)`, `hazar`, `ہزار` (× 1,000); `lakh(s)`, `lac(s)`,
48
+ * `لاکھ` (× 100,000); `crore(s)`, `cr`, `کروڑ` (× 10,000,000). Decimals
49
+ * work with units: `1.5 lakh` is 150,000 and `2.25cr` is 22,500,000;
50
+ * - whitespace around and between the parts (spaces, tabs, line breaks and
51
+ * no-break spaces).
52
+ *
53
+ * Rejected (`null`): empty input, negative or signed amounts (`-500`,
54
+ * `+500`), ranges (`5-10k`), more than one number (`500 600`), two currency
55
+ * marks or two units, leftover letters (`500 rupees`, `5kk`), grouping that
56
+ * could be read two ways or is broken (`1,50`, `1.500,00`, `1,5000`), and
57
+ * amounts over Rs. 50 trillion (50 lakh crore), beyond which a number can no
58
+ * longer hold every paisa exactly.
59
+ *
60
+ * The arithmetic is done on the digits, so the result is exact: `1.005`
61
+ * rounds to 1.01 and `1.5 lakh` is exactly 150000.
62
+ *
63
+ * @param input - The amount as typed
64
+ * @returns `{ value, raw }`, or `null` if the input is not one amount
65
+ * @example
66
+ * parseAmount('Rs. 1,50,000/-'); // { value: 150000, raw: 'Rs. 1,50,000/-' }
67
+ * parseAmount('2.25cr'); // { value: 22500000, raw: '2.25cr' }
68
+ * parseAmount('5-10k'); // null
69
+ */
70
+ declare function parseAmount(input: string): ParsedAmount | null;
71
+ /**
72
+ * Writes back an amount typed in any form {@link parseAmount} accepts, for
73
+ * showing next to the field ("= Rs. 150,000"): `Rs.`, international
74
+ * grouping, and paisa only when there are any (`Rs. 1,234.50`). Returns
75
+ * `null` when `parseAmount` does; it never throws.
76
+ *
77
+ * @param input - The amount as typed
78
+ * @returns E.g. `"Rs. 150,000"` for `"1.5 lakh"`, or `null`
79
+ */
80
+ declare function formatAmountInput(input: string): string | null;
26
81
 
27
- export { formatLakh, formatPKR };
82
+ export { formatAmountInput, formatLakh, formatPKR, parseAmount };
83
+ export type { ParsedAmount };
package/dist/format.d.ts CHANGED
@@ -23,5 +23,61 @@ declare function formatPKR(amount: number): string;
23
23
  * @throws {RangeError} If `amount` is `NaN` or infinite
24
24
  */
25
25
  declare function formatLakh(amount: number): string;
26
+ /** The result of {@link parseAmount}. */
27
+ interface ParsedAmount {
28
+ /** The amount in rupees, rounded half-up to the paisa (2 decimals). */
29
+ value: number;
30
+ /** The input with surrounding whitespace removed. */
31
+ raw: string;
32
+ }
33
+ /**
34
+ * Reads a rupee amount the way people type it in Pakistan, and returns it in
35
+ * rupees, rounded half-up to the paisa. Returns `null` for anything that is
36
+ * not exactly one non-negative amount; it never throws.
37
+ *
38
+ * Accepted:
39
+ * - digits, with or without grouping: `150000`, `150,000` (international) or
40
+ * `1,50,000` (Pakistani: groups of two, then three), and decimals
41
+ * (`1,234.50`, `.5`, `5.`); a grouping must be complete and consistent;
42
+ * - Urdu (`۱۵۰۰۰۰`) and Arabic-Indic (`١٥٠٠٠٠`) digits, also mixed with
43
+ * 0-9, and the Arabic decimal and thousands separators (`٫`, `٬`);
44
+ * - one currency mark before or after the number: `Rs`, `Rs.`, `PKR` or `₨`
45
+ * (any case), and a trailing `/-` (`Rs. 5,000/-`);
46
+ * - one shorthand unit after the number, with or without a space, in any
47
+ * case: `k`, `thousand(s)`, `hazar`, `ہزار` (× 1,000); `lakh(s)`, `lac(s)`,
48
+ * `لاکھ` (× 100,000); `crore(s)`, `cr`, `کروڑ` (× 10,000,000). Decimals
49
+ * work with units: `1.5 lakh` is 150,000 and `2.25cr` is 22,500,000;
50
+ * - whitespace around and between the parts (spaces, tabs, line breaks and
51
+ * no-break spaces).
52
+ *
53
+ * Rejected (`null`): empty input, negative or signed amounts (`-500`,
54
+ * `+500`), ranges (`5-10k`), more than one number (`500 600`), two currency
55
+ * marks or two units, leftover letters (`500 rupees`, `5kk`), grouping that
56
+ * could be read two ways or is broken (`1,50`, `1.500,00`, `1,5000`), and
57
+ * amounts over Rs. 50 trillion (50 lakh crore), beyond which a number can no
58
+ * longer hold every paisa exactly.
59
+ *
60
+ * The arithmetic is done on the digits, so the result is exact: `1.005`
61
+ * rounds to 1.01 and `1.5 lakh` is exactly 150000.
62
+ *
63
+ * @param input - The amount as typed
64
+ * @returns `{ value, raw }`, or `null` if the input is not one amount
65
+ * @example
66
+ * parseAmount('Rs. 1,50,000/-'); // { value: 150000, raw: 'Rs. 1,50,000/-' }
67
+ * parseAmount('2.25cr'); // { value: 22500000, raw: '2.25cr' }
68
+ * parseAmount('5-10k'); // null
69
+ */
70
+ declare function parseAmount(input: string): ParsedAmount | null;
71
+ /**
72
+ * Writes back an amount typed in any form {@link parseAmount} accepts, for
73
+ * showing next to the field ("= Rs. 150,000"): `Rs.`, international
74
+ * grouping, and paisa only when there are any (`Rs. 1,234.50`). Returns
75
+ * `null` when `parseAmount` does; it never throws.
76
+ *
77
+ * @param input - The amount as typed
78
+ * @returns E.g. `"Rs. 150,000"` for `"1.5 lakh"`, or `null`
79
+ */
80
+ declare function formatAmountInput(input: string): string | null;
26
81
 
27
- export { formatLakh, formatPKR };
82
+ export { formatAmountInput, formatLakh, formatPKR, parseAmount };
83
+ export type { ParsedAmount };
package/dist/format.js CHANGED
@@ -1 +1 @@
1
- export { formatLakh, formatPKR } from './chunk-6TSKA2PH.js';
1
+ export { formatAmountInput, formatLakh, formatPKR, parseAmount } from './chunk-NDW52ZK3.js';
package/dist/index.cjs CHANGED
@@ -25,7 +25,7 @@ var chunkYPAWNWFD_cjs = require('./chunk-YPAWNWFD.cjs');
25
25
  var chunk5UCRHVI4_cjs = require('./chunk-5UCRHVI4.cjs');
26
26
  var chunkCF6AMRBU_cjs = require('./chunk-CF6AMRBU.cjs');
27
27
  require('./chunk-SF4ECUZ6.cjs');
28
- var chunkLVHTH4P7_cjs = require('./chunk-LVHTH4P7.cjs');
28
+ var chunkNLSIAPZG_cjs = require('./chunk-NLSIAPZG.cjs');
29
29
  var chunk33GOK7EE_cjs = require('./chunk-33GOK7EE.cjs');
30
30
  require('./chunk-E6GWBOKV.cjs');
31
31
  require('./chunk-VPBMIYO2.cjs');
@@ -345,13 +345,21 @@ Object.defineProperty(exports, "splitInclusive", {
345
345
  enumerable: true,
346
346
  get: function () { return chunkCF6AMRBU_cjs.splitInclusive; }
347
347
  });
348
+ Object.defineProperty(exports, "formatAmountInput", {
349
+ enumerable: true,
350
+ get: function () { return chunkNLSIAPZG_cjs.formatAmountInput; }
351
+ });
348
352
  Object.defineProperty(exports, "formatLakh", {
349
353
  enumerable: true,
350
- get: function () { return chunkLVHTH4P7_cjs.formatLakh; }
354
+ get: function () { return chunkNLSIAPZG_cjs.formatLakh; }
351
355
  });
352
356
  Object.defineProperty(exports, "formatPKR", {
353
357
  enumerable: true,
354
- get: function () { return chunkLVHTH4P7_cjs.formatPKR; }
358
+ get: function () { return chunkNLSIAPZG_cjs.formatPKR; }
359
+ });
360
+ Object.defineProperty(exports, "parseAmount", {
361
+ enumerable: true,
362
+ get: function () { return chunkNLSIAPZG_cjs.parseAmount; }
355
363
  });
356
364
  Object.defineProperty(exports, "getDistrictProvince", {
357
365
  enumerable: true,
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ export { CNICInfo, getCNICInfo, validateCNIC } from './cnic.cjs';
2
2
  export { PhoneAnalysis, analyzePhone, formatPhone, validatePhone } from './phone.cjs';
3
3
  export { NetworkName, getNetwork } from './networks.cjs';
4
4
  export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts } from './geo.cjs';
5
- export { formatLakh, formatPKR } from './format.cjs';
5
+ export { ParsedAmount, formatAmountInput, formatLakh, formatPKR, parseAmount } from './format.cjs';
6
6
  export { createWhatsAppLink } from './whatsapp.cjs';
7
7
  export { BankInfo, BankType, getBankFromIBAN, getBankInfo, getBanks, validateIBAN } from './iban.cjs';
8
8
  export { PostOffice, getCityByPostalCode, getPostOffice, getPostalAreas, getPostalCode, getPostalCodes, searchPostOffices, searchPostalCodes } from './postal.cjs';
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ export { CNICInfo, getCNICInfo, validateCNIC } from './cnic.js';
2
2
  export { PhoneAnalysis, analyzePhone, formatPhone, validatePhone } from './phone.js';
3
3
  export { NetworkName, getNetwork } from './networks.js';
4
4
  export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts } from './geo.js';
5
- export { formatLakh, formatPKR } from './format.js';
5
+ export { ParsedAmount, formatAmountInput, formatLakh, formatPKR, parseAmount } from './format.js';
6
6
  export { createWhatsAppLink } from './whatsapp.js';
7
7
  export { BankInfo, BankType, getBankFromIBAN, getBankInfo, getBanks, validateIBAN } from './iban.js';
8
8
  export { PostOffice, getCityByPostalCode, getPostOffice, getPostalAreas, getPostalCode, getPostalCodes, searchPostOffices, searchPostalCodes } from './postal.js';
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ export { mapCourierStatus, normalizeCityForCourier } from './chunk-4GSBHJX6.js';
23
23
  export { FBR_DI_SPEC_VERSION, buildFbrInvoice, expectedSalesTax, validateFbrInvoice } from './chunk-OTI7HY55.js';
24
24
  export { calculateSalesTax, getSalesTaxRate, splitInclusive } from './chunk-34U2ZMHR.js';
25
25
  import './chunk-5EY5DQS7.js';
26
- export { formatLakh, formatPKR } from './chunk-6TSKA2PH.js';
26
+ export { formatAmountInput, formatLakh, formatPKR, parseAmount } from './chunk-NDW52ZK3.js';
27
27
  export { getDistrictProvince, getDistrictsByProvince, getDivisionOfDistrict, getDivisions, getProvince, getTehsilDistrict, getTehsils, searchCities, searchDistricts } from './chunk-XOTCIXY6.js';
28
28
  import './chunk-E2XU6NOW.js';
29
29
  import './chunk-ENQ7O7VW.js';
package/dist/joi.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkXCFZKCV2_cjs = require('./chunk-XCFZKCV2.cjs');
3
+ var chunkYSRYWZCQ_cjs = require('./chunk-YSRYWZCQ.cjs');
4
4
  require('./chunk-ESKXG7Y6.cjs');
5
5
  require('./chunk-YDUXIENX.cjs');
6
6
  require('./chunk-H6M6L26S.cjs');
@@ -13,6 +13,7 @@ require('./chunk-7E7L3NYS.cjs');
13
13
  require('./chunk-QFPEFD67.cjs');
14
14
  require('./chunk-I7UUPD3G.cjs');
15
15
  require('./chunk-HTCSHHOR.cjs');
16
+ require('./chunk-NLSIAPZG.cjs');
16
17
  require('./chunk-33GOK7EE.cjs');
17
18
  require('./chunk-E6GWBOKV.cjs');
18
19
  require('./chunk-VPBMIYO2.cjs');
@@ -23,7 +24,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
23
24
  var Joi__default = /*#__PURE__*/_interopDefault(Joi);
24
25
 
25
26
  function schema(name) {
26
- const rule = chunkXCFZKCV2_cjs.RULES[name];
27
+ const rule = chunkYSRYWZCQ_cjs.RULES[name];
27
28
  return (options = {}) => Joi__default.default.string().custom(
28
29
  (value, helpers) => rule.test(value) ? value : helpers.message({ custom: options.message ?? rule.message })
29
30
  );
@@ -37,7 +38,8 @@ var pk = {
37
38
  landline: schema("landline"),
38
39
  passport: schema("passport"),
39
40
  vehiclePlate: schema("vehiclePlate"),
40
- codPhone: schema("codPhone")
41
+ codPhone: schema("codPhone"),
42
+ amount: schema("amount")
41
43
  };
42
44
 
43
45
  exports.pk = pk;
package/dist/joi.d.cts CHANGED
@@ -20,6 +20,7 @@ declare const pk: {
20
20
  passport: (options?: AdapterOptions) => Joi.StringSchema<string>;
21
21
  vehiclePlate: (options?: AdapterOptions) => Joi.StringSchema<string>;
22
22
  codPhone: (options?: AdapterOptions) => Joi.StringSchema<string>;
23
+ amount: (options?: AdapterOptions) => Joi.StringSchema<string>;
23
24
  };
24
25
 
25
26
  export { AdapterOptions, pk };
package/dist/joi.d.ts CHANGED
@@ -20,6 +20,7 @@ declare const pk: {
20
20
  passport: (options?: AdapterOptions) => Joi.StringSchema<string>;
21
21
  vehiclePlate: (options?: AdapterOptions) => Joi.StringSchema<string>;
22
22
  codPhone: (options?: AdapterOptions) => Joi.StringSchema<string>;
23
+ amount: (options?: AdapterOptions) => Joi.StringSchema<string>;
23
24
  };
24
25
 
25
26
  export { AdapterOptions, pk };
package/dist/joi.js CHANGED
@@ -1,4 +1,4 @@
1
- import { RULES } from './chunk-IDTRFOQW.js';
1
+ import { RULES } from './chunk-QG5T7YQ5.js';
2
2
  import './chunk-S274QFFB.js';
3
3
  import './chunk-UYFTXD4P.js';
4
4
  import './chunk-CEPNSHIC.js';
@@ -11,6 +11,7 @@ import './chunk-E6HSKRAE.js';
11
11
  import './chunk-B7DOQ5QF.js';
12
12
  import './chunk-33QMFE2Z.js';
13
13
  import './chunk-EEVNLTB4.js';
14
+ import './chunk-NDW52ZK3.js';
14
15
  import './chunk-XOTCIXY6.js';
15
16
  import './chunk-E2XU6NOW.js';
16
17
  import './chunk-ENQ7O7VW.js';
@@ -31,7 +32,8 @@ var pk = {
31
32
  landline: schema("landline"),
32
33
  passport: schema("passport"),
33
34
  vehiclePlate: schema("vehiclePlate"),
34
- codPhone: schema("codPhone")
35
+ codPhone: schema("codPhone"),
36
+ amount: schema("amount")
35
37
  };
36
38
 
37
39
  export { pk };
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkXCFZKCV2_cjs = require('./chunk-XCFZKCV2.cjs');
3
+ var chunkYSRYWZCQ_cjs = require('./chunk-YSRYWZCQ.cjs');
4
4
  require('./chunk-ESKXG7Y6.cjs');
5
5
  require('./chunk-YDUXIENX.cjs');
6
6
  require('./chunk-H6M6L26S.cjs');
@@ -13,13 +13,14 @@ require('./chunk-7E7L3NYS.cjs');
13
13
  require('./chunk-QFPEFD67.cjs');
14
14
  require('./chunk-I7UUPD3G.cjs');
15
15
  require('./chunk-HTCSHHOR.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 superstruct = require('superstruct');
20
21
 
21
22
  function schema(name) {
22
- const rule = chunkXCFZKCV2_cjs.RULES[name];
23
+ const rule = chunkYSRYWZCQ_cjs.RULES[name];
23
24
  return (options = {}) => superstruct.refine(
24
25
  superstruct.string(),
25
26
  `pk-${name}`,
@@ -35,7 +36,8 @@ var pk = {
35
36
  landline: schema("landline"),
36
37
  passport: schema("passport"),
37
38
  vehiclePlate: schema("vehiclePlate"),
38
- codPhone: schema("codPhone")
39
+ codPhone: schema("codPhone"),
40
+ amount: schema("amount")
39
41
  };
40
42
 
41
43
  exports.pk = pk;
@@ -20,6 +20,7 @@ declare const pk: {
20
20
  passport: (options?: AdapterOptions) => superstruct.Struct<string, null>;
21
21
  vehiclePlate: (options?: AdapterOptions) => superstruct.Struct<string, null>;
22
22
  codPhone: (options?: AdapterOptions) => superstruct.Struct<string, null>;
23
+ amount: (options?: AdapterOptions) => superstruct.Struct<string, null>;
23
24
  };
24
25
 
25
26
  export { AdapterOptions, pk };
@@ -20,6 +20,7 @@ declare const pk: {
20
20
  passport: (options?: AdapterOptions) => superstruct.Struct<string, null>;
21
21
  vehiclePlate: (options?: AdapterOptions) => superstruct.Struct<string, null>;
22
22
  codPhone: (options?: AdapterOptions) => superstruct.Struct<string, null>;
23
+ amount: (options?: AdapterOptions) => superstruct.Struct<string, null>;
23
24
  };
24
25
 
25
26
  export { AdapterOptions, pk };
@@ -1,4 +1,4 @@
1
- import { RULES } from './chunk-IDTRFOQW.js';
1
+ import { RULES } from './chunk-QG5T7YQ5.js';
2
2
  import './chunk-S274QFFB.js';
3
3
  import './chunk-UYFTXD4P.js';
4
4
  import './chunk-CEPNSHIC.js';
@@ -11,6 +11,7 @@ import './chunk-E6HSKRAE.js';
11
11
  import './chunk-B7DOQ5QF.js';
12
12
  import './chunk-33QMFE2Z.js';
13
13
  import './chunk-EEVNLTB4.js';
14
+ import './chunk-NDW52ZK3.js';
14
15
  import './chunk-XOTCIXY6.js';
15
16
  import './chunk-E2XU6NOW.js';
16
17
  import './chunk-ENQ7O7VW.js';
@@ -33,7 +34,8 @@ var pk = {
33
34
  landline: schema("landline"),
34
35
  passport: schema("passport"),
35
36
  vehiclePlate: schema("vehiclePlate"),
36
- codPhone: schema("codPhone")
37
+ codPhone: schema("codPhone"),
38
+ amount: schema("amount")
37
39
  };
38
40
 
39
41
  export { pk };