@hy_ong/zod-kit 0.2.2 → 0.2.4

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 (135) hide show
  1. package/dist/{chunk-JXY7APBU.js → chunk-2JGRV3JO.js} +1 -1
  2. package/dist/{chunk-FM3EZ72O.js → chunk-3QLUXIY2.js} +1 -1
  3. package/dist/chunk-3ZF5JO3F.js +61 -0
  4. package/dist/{chunk-STNHTRG7.cjs → chunk-4AQB4RSU.cjs} +3 -3
  5. package/dist/{chunk-OPQJWHXN.cjs → chunk-53EEWALQ.cjs} +3 -3
  6. package/dist/{chunk-ZNJLWJX3.cjs → chunk-5ZMTAI4G.cjs} +3 -3
  7. package/dist/{chunk-RKUQREMW.js → chunk-6DFP7XY2.js} +1 -1
  8. package/dist/{chunk-5LEXCVLX.js → chunk-6IAPM7BP.js} +1 -1
  9. package/dist/{chunk-RO47DKQG.js → chunk-7SKH66CM.js} +1 -1
  10. package/dist/chunk-7X3XPK6A.js +92 -0
  11. package/dist/{chunk-UBK3VCVH.cjs → chunk-A2GAEU4O.cjs} +3 -3
  12. package/dist/{chunk-KFOHKTFD.js → chunk-AI4U42JV.js} +1 -1
  13. package/dist/{chunk-ERH4NIMU.cjs → chunk-AYCXAJRA.cjs} +3 -3
  14. package/dist/{chunk-YDH3L27K.cjs → chunk-BZSPJJYT.cjs} +3 -3
  15. package/dist/chunk-BZWQPSHO.cjs +92 -0
  16. package/dist/{chunk-H2XTEM4M.js → chunk-D55YFP5R.js} +1 -1
  17. package/dist/{chunk-LL4ZWLGO.js → chunk-E52GRXYY.js} +1 -1
  18. package/dist/{chunk-RRPXIRTQ.cjs → chunk-EDTNS2XL.cjs} +3 -3
  19. package/dist/{chunk-RYFG2GKM.cjs → chunk-FEL432I2.cjs} +3 -3
  20. package/dist/chunk-FMPHW7ID.cjs +61 -0
  21. package/dist/{chunk-JOLSGZGN.cjs → chunk-FP4O2ICM.cjs} +3 -3
  22. package/dist/{chunk-EGHL277K.cjs → chunk-G747FHUZ.cjs} +3 -3
  23. package/dist/{chunk-5JGTDL3Y.js → chunk-G7FLGJYD.js} +1 -1
  24. package/dist/{chunk-HMSM6FFA.cjs → chunk-H25N5GP6.cjs} +3 -3
  25. package/dist/{chunk-MHJFYYGV.js → chunk-H6STFX4I.js} +1 -1
  26. package/dist/{chunk-EDHT4LPO.js → chunk-HQ4RAMSD.js} +1 -1
  27. package/dist/{chunk-ORFHDJII.cjs → chunk-HZ2WESSL.cjs} +3 -3
  28. package/dist/{chunk-ORVV4MCF.cjs → chunk-IWR3H7IH.cjs} +3 -3
  29. package/dist/{chunk-B4EZYZOK.cjs → chunk-JZEF5Q3W.cjs} +3 -3
  30. package/dist/{chunk-HTEHINI7.cjs → chunk-KIUO2HIR.cjs} +3 -3
  31. package/dist/{chunk-QICQ6YEY.js → chunk-LBH5U2DZ.js} +1 -1
  32. package/dist/{chunk-42C5OHRK.js → chunk-LC4RNKBM.js} +1 -1
  33. package/dist/{chunk-TFGS34VD.cjs → chunk-LNWEJED7.cjs} +3 -3
  34. package/dist/{chunk-32JI34CV.cjs → chunk-LXFRQLH4.cjs} +3 -3
  35. package/dist/{chunk-46VAH2BJ.js → chunk-NWQSOSNF.js} +1 -1
  36. package/dist/{chunk-WDI4QJMQ.js → chunk-OGU7AIZF.js} +1 -1
  37. package/dist/{chunk-YIM3D2AD.js → chunk-OKO6WO6M.js} +1 -1
  38. package/dist/{chunk-MINMXGW3.js → chunk-OSUPJCBA.js} +1 -1
  39. package/dist/{chunk-6AAP4LPF.js → chunk-POIDES2L.js} +110 -0
  40. package/dist/{chunk-YPSEIDUR.cjs → chunk-Q24GYUTO.cjs} +3 -3
  41. package/dist/{chunk-UCOXAZJF.cjs → chunk-Q7TUNJD4.cjs} +110 -0
  42. package/dist/{chunk-L4HSIKTU.cjs → chunk-QQWX3ICK.cjs} +3 -3
  43. package/dist/{chunk-COYKBWTI.js → chunk-RFWCYULE.js} +1 -1
  44. package/dist/{chunk-ZXUMK2RR.js → chunk-RHKBT3M2.js} +1 -1
  45. package/dist/{chunk-LH7ZB4BK.js → chunk-RVGCMQ4J.js} +1 -1
  46. package/dist/{chunk-K2UOY6TB.js → chunk-T7PG4JDW.js} +1 -1
  47. package/dist/{chunk-DFJZ3NS2.cjs → chunk-TDEXEIHH.cjs} +3 -3
  48. package/dist/{chunk-GJIRDBZJ.cjs → chunk-TPXRQT2H.cjs} +3 -3
  49. package/dist/{chunk-UQZKFAFX.js → chunk-TRQMRHFM.js} +1 -1
  50. package/dist/{chunk-WABKPFPK.js → chunk-U2PB6XEO.js} +1 -1
  51. package/dist/{chunk-ZTFCJCPO.cjs → chunk-UCPKW43K.cjs} +3 -3
  52. package/dist/{chunk-TQXDUMML.cjs → chunk-V2KKGSKQ.cjs} +3 -3
  53. package/dist/{chunk-VB2KV2ZM.cjs → chunk-VKBNKPFO.cjs} +3 -3
  54. package/dist/{chunk-MM7IL2RG.js → chunk-XAN4CAVH.js} +1 -1
  55. package/dist/{chunk-M6MTP3NY.cjs → chunk-ZCX22PY4.cjs} +3 -3
  56. package/dist/{chunk-2SWEVDFZ.js → chunk-ZXPRRNZR.js} +1 -1
  57. package/dist/common/boolean.cjs +3 -3
  58. package/dist/common/boolean.js +2 -2
  59. package/dist/common/color.cjs +3 -3
  60. package/dist/common/color.js +2 -2
  61. package/dist/common/coordinate.cjs +3 -3
  62. package/dist/common/coordinate.js +2 -2
  63. package/dist/common/credit-card.cjs +3 -3
  64. package/dist/common/credit-card.js +2 -2
  65. package/dist/common/date.cjs +3 -3
  66. package/dist/common/date.js +2 -2
  67. package/dist/common/datetime.cjs +3 -3
  68. package/dist/common/datetime.js +2 -2
  69. package/dist/common/email.cjs +3 -3
  70. package/dist/common/email.js +2 -2
  71. package/dist/common/file.cjs +3 -3
  72. package/dist/common/file.js +2 -2
  73. package/dist/common/id.cjs +3 -3
  74. package/dist/common/id.js +2 -2
  75. package/dist/common/ip.cjs +3 -3
  76. package/dist/common/ip.js +2 -2
  77. package/dist/common/many-of.cjs +7 -0
  78. package/dist/common/many-of.d.cts +111 -0
  79. package/dist/common/many-of.d.ts +111 -0
  80. package/dist/common/many-of.js +7 -0
  81. package/dist/common/number.cjs +3 -3
  82. package/dist/common/number.js +2 -2
  83. package/dist/common/one-of.cjs +7 -0
  84. package/dist/common/one-of.d.cts +104 -0
  85. package/dist/common/one-of.d.ts +104 -0
  86. package/dist/common/one-of.js +7 -0
  87. package/dist/common/password.cjs +3 -3
  88. package/dist/common/password.js +2 -2
  89. package/dist/common/text.cjs +3 -3
  90. package/dist/common/text.js +2 -2
  91. package/dist/common/time.cjs +3 -3
  92. package/dist/common/time.js +2 -2
  93. package/dist/common/url.cjs +3 -3
  94. package/dist/common/url.js +2 -2
  95. package/dist/index.cjs +35 -27
  96. package/dist/index.d.cts +2 -0
  97. package/dist/index.d.ts +2 -0
  98. package/dist/index.js +46 -38
  99. package/dist/taiwan/bank-account.cjs +3 -3
  100. package/dist/taiwan/bank-account.js +2 -2
  101. package/dist/taiwan/business-id.cjs +3 -3
  102. package/dist/taiwan/business-id.js +2 -2
  103. package/dist/taiwan/fax.cjs +3 -3
  104. package/dist/taiwan/fax.js +2 -2
  105. package/dist/taiwan/invoice.cjs +3 -3
  106. package/dist/taiwan/invoice.js +2 -2
  107. package/dist/taiwan/license-plate.cjs +3 -3
  108. package/dist/taiwan/license-plate.js +2 -2
  109. package/dist/taiwan/mobile.cjs +3 -3
  110. package/dist/taiwan/mobile.js +2 -2
  111. package/dist/taiwan/national-id.cjs +3 -3
  112. package/dist/taiwan/national-id.js +2 -2
  113. package/dist/taiwan/passport.cjs +3 -3
  114. package/dist/taiwan/passport.js +2 -2
  115. package/dist/taiwan/postal-code.cjs +3 -3
  116. package/dist/taiwan/postal-code.js +2 -2
  117. package/dist/taiwan/tel.cjs +3 -3
  118. package/dist/taiwan/tel.js +2 -2
  119. package/package.json +11 -1
  120. package/src/i18n/locales/en-GB.json +11 -0
  121. package/src/i18n/locales/en-US.json +11 -0
  122. package/src/i18n/locales/id-ID.json +11 -0
  123. package/src/i18n/locales/ja-JP.json +11 -0
  124. package/src/i18n/locales/ko-KR.json +11 -0
  125. package/src/i18n/locales/ms-MY.json +11 -0
  126. package/src/i18n/locales/th-TH.json +11 -0
  127. package/src/i18n/locales/vi-VN.json +11 -0
  128. package/src/i18n/locales/zh-CN.json +11 -0
  129. package/src/i18n/locales/zh-TW.json +11 -0
  130. package/src/index.ts +2 -0
  131. package/src/validators/common/many-of.ts +219 -0
  132. package/src/validators/common/one-of.ts +172 -0
  133. package/tests/common/many-of.test.ts +198 -0
  134. package/tests/common/one-of.test.ts +136 -0
  135. package/tsup.config.ts +2 -0
@@ -4,12 +4,12 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkOPQJWHXNcjs = require('../chunk-OPQJWHXN.cjs');
8
- require('../chunk-UCOXAZJF.cjs');
7
+ var _chunk53EEWALQcjs = require('../chunk-53EEWALQ.cjs');
8
+ require('../chunk-Q7TUNJD4.cjs');
9
9
 
10
10
 
11
11
 
12
12
 
13
13
 
14
14
 
15
- exports.DATETIME_PATTERNS = _chunkOPQJWHXNcjs.DATETIME_PATTERNS; exports.datetime = _chunkOPQJWHXNcjs.datetime; exports.normalizeDateTimeValue = _chunkOPQJWHXNcjs.normalizeDateTimeValue; exports.parseDateTimeValue = _chunkOPQJWHXNcjs.parseDateTimeValue; exports.validateDateTimeFormat = _chunkOPQJWHXNcjs.validateDateTimeFormat;
15
+ exports.DATETIME_PATTERNS = _chunk53EEWALQcjs.DATETIME_PATTERNS; exports.datetime = _chunk53EEWALQcjs.datetime; exports.normalizeDateTimeValue = _chunk53EEWALQcjs.normalizeDateTimeValue; exports.parseDateTimeValue = _chunk53EEWALQcjs.parseDateTimeValue; exports.validateDateTimeFormat = _chunk53EEWALQcjs.validateDateTimeFormat;
@@ -4,8 +4,8 @@ import {
4
4
  normalizeDateTimeValue,
5
5
  parseDateTimeValue,
6
6
  validateDateTimeFormat
7
- } from "../chunk-ZXUMK2RR.js";
8
- import "../chunk-6AAP4LPF.js";
7
+ } from "../chunk-RHKBT3M2.js";
8
+ import "../chunk-POIDES2L.js";
9
9
  export {
10
10
  DATETIME_PATTERNS,
11
11
  datetime,
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkHMSM6FFAcjs = require('../chunk-HMSM6FFA.cjs');
4
- require('../chunk-UCOXAZJF.cjs');
3
+ var _chunkH25N5GP6cjs = require('../chunk-H25N5GP6.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
5
 
6
6
 
7
- exports.email = _chunkHMSM6FFAcjs.email;
7
+ exports.email = _chunkH25N5GP6cjs.email;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  email
3
- } from "../chunk-MM7IL2RG.js";
4
- import "../chunk-6AAP4LPF.js";
3
+ } from "../chunk-XAN4CAVH.js";
4
+ import "../chunk-POIDES2L.js";
5
5
  export {
6
6
  email
7
7
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkHTEHINI7cjs = require('../chunk-HTEHINI7.cjs');
4
- require('../chunk-UCOXAZJF.cjs');
3
+ var _chunkKIUO2HIRcjs = require('../chunk-KIUO2HIR.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
5
 
6
6
 
7
- exports.file = _chunkHTEHINI7cjs.file;
7
+ exports.file = _chunkKIUO2HIRcjs.file;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  file
3
- } from "../chunk-WDI4QJMQ.js";
4
- import "../chunk-6AAP4LPF.js";
3
+ } from "../chunk-OGU7AIZF.js";
4
+ import "../chunk-POIDES2L.js";
5
5
  export {
6
6
  file
7
7
  };
@@ -3,11 +3,11 @@
3
3
 
4
4
 
5
5
 
6
- var _chunkB4EZYZOKcjs = require('../chunk-B4EZYZOK.cjs');
7
- require('../chunk-UCOXAZJF.cjs');
6
+ var _chunkJZEF5Q3Wcjs = require('../chunk-JZEF5Q3W.cjs');
7
+ require('../chunk-Q7TUNJD4.cjs');
8
8
 
9
9
 
10
10
 
11
11
 
12
12
 
13
- exports.ID_PATTERNS = _chunkB4EZYZOKcjs.ID_PATTERNS; exports.detectIdType = _chunkB4EZYZOKcjs.detectIdType; exports.id = _chunkB4EZYZOKcjs.id; exports.validateIdType = _chunkB4EZYZOKcjs.validateIdType;
13
+ exports.ID_PATTERNS = _chunkJZEF5Q3Wcjs.ID_PATTERNS; exports.detectIdType = _chunkJZEF5Q3Wcjs.detectIdType; exports.id = _chunkJZEF5Q3Wcjs.id; exports.validateIdType = _chunkJZEF5Q3Wcjs.validateIdType;
package/dist/common/id.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  detectIdType,
4
4
  id,
5
5
  validateIdType
6
- } from "../chunk-MHJFYYGV.js";
7
- import "../chunk-6AAP4LPF.js";
6
+ } from "../chunk-H6STFX4I.js";
7
+ import "../chunk-POIDES2L.js";
8
8
  export {
9
9
  ID_PATTERNS,
10
10
  detectIdType,
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk32JI34CVcjs = require('../chunk-32JI34CV.cjs');
6
- require('../chunk-UCOXAZJF.cjs');
5
+ var _chunkLXFRQLH4cjs = require('../chunk-LXFRQLH4.cjs');
6
+ require('../chunk-Q7TUNJD4.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.ip = _chunk32JI34CVcjs.ip; exports.validateIPv4 = _chunk32JI34CVcjs.validateIPv4; exports.validateIPv6 = _chunk32JI34CVcjs.validateIPv6;
11
+ exports.ip = _chunkLXFRQLH4cjs.ip; exports.validateIPv4 = _chunkLXFRQLH4cjs.validateIPv4; exports.validateIPv6 = _chunkLXFRQLH4cjs.validateIPv6;
package/dist/common/ip.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  ip,
3
3
  validateIPv4,
4
4
  validateIPv6
5
- } from "../chunk-RO47DKQG.js";
6
- import "../chunk-6AAP4LPF.js";
5
+ } from "../chunk-7SKH66CM.js";
6
+ import "../chunk-POIDES2L.js";
7
7
  export {
8
8
  ip,
9
9
  validateIPv4,
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkBZWQPSHOcjs = require('../chunk-BZWQPSHO.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
+
6
+
7
+ exports.manyOf = _chunkBZWQPSHOcjs.manyOf;
@@ -0,0 +1,111 @@
1
+ import { ZodType } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.cjs';
3
+
4
+ /**
5
+ * @fileoverview ManyOf validator for Zod Kit
6
+ *
7
+ * Provides multi-select validation that restricts input to an array of values
8
+ * from a predefined set, with min/max selection, duplicate control, and transformation.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.2.2
12
+ */
13
+
14
+ /**
15
+ * Type definition for manyOf validation error messages
16
+ *
17
+ * @interface ManyOfMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when a value is not in the allowed list
20
+ * @property {string} [minSelect] - Message when fewer than minimum items are selected
21
+ * @property {string} [maxSelect] - Message when more than maximum items are selected
22
+ * @property {string} [duplicate] - Message when duplicate values are found
23
+ */
24
+ type ManyOfMessages = {
25
+ required?: string;
26
+ invalid?: string;
27
+ minSelect?: string;
28
+ maxSelect?: string;
29
+ duplicate?: string;
30
+ };
31
+ /**
32
+ * Configuration options for manyOf validation
33
+ *
34
+ * @template IsRequired - Whether the field is required (affects return type)
35
+ * @template T - The type of allowed values
36
+ *
37
+ * @interface ManyOfOptions
38
+ * @property {T[]} values - Array of allowed values
39
+ * @property {T[] | null} [defaultValue] - Default value when input is empty
40
+ * @property {number} [min] - Minimum number of selections
41
+ * @property {number} [max] - Maximum number of selections
42
+ * @property {boolean} [allowDuplicates=false] - Whether to allow duplicate selections
43
+ * @property {boolean} [caseSensitive=true] - Whether string matching is case-sensitive
44
+ * @property {Function} [transform] - Custom transformation function applied to each value
45
+ * @property {Record<Locale, ManyOfMessages>} [i18n] - Custom error messages for different locales
46
+ */
47
+ type ManyOfOptions<IsRequired extends boolean = true, V extends readonly (string | number)[] = readonly (string | number)[]> = {
48
+ values: V;
49
+ defaultValue?: IsRequired extends true ? V[number][] : V[number][] | null;
50
+ min?: number;
51
+ max?: number;
52
+ allowDuplicates?: boolean;
53
+ caseSensitive?: boolean;
54
+ transform?: (value: V[number][]) => V[number][];
55
+ i18n?: Partial<Record<Locale, Partial<ManyOfMessages>>>;
56
+ };
57
+ /**
58
+ * Type alias for manyOf validation schema based on required flag
59
+ *
60
+ * @template IsRequired - Whether the field is required
61
+ * @template T - The type of allowed values
62
+ */
63
+ type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number][]> : ZodType<V[number][] | null>;
64
+ /**
65
+ * Creates a Zod schema for multi-select validation that restricts values to a predefined set
66
+ *
67
+ * @template IsRequired - Whether the field is required (affects return type)
68
+ * @template T - The type of allowed values (string | number)
69
+ * @param {IsRequired} [required=false] - Whether the field is required
70
+ * @param {ManyOfOptions<IsRequired, T>} options - Configuration options (values is required)
71
+ * @returns {ManyOfSchema<IsRequired, T>} Zod schema for manyOf validation
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Basic multi-select (optional by default)
76
+ * const tagsSchema = manyOf(false, { values: ["js", "ts", "rust", "go"] })
77
+ * tagsSchema.parse(["js", "ts"]) // ✓ ["js", "ts"]
78
+ * tagsSchema.parse(null) // ✓ null
79
+ *
80
+ * // Required with min/max
81
+ * const skillsSchema = manyOf(true, {
82
+ * values: ["react", "vue", "angular", "svelte"],
83
+ * min: 1,
84
+ * max: 3,
85
+ * })
86
+ * skillsSchema.parse(["react"]) // ✓
87
+ * skillsSchema.parse([]) // ✗ minSelect
88
+ * skillsSchema.parse(["react", "vue", "angular", "svelte"]) // ✗ maxSelect
89
+ *
90
+ * // Case-insensitive matching
91
+ * const colorsSchema = manyOf(true, {
92
+ * values: ["red", "green", "blue"],
93
+ * caseSensitive: false,
94
+ * })
95
+ * colorsSchema.parse(["RED", "Green"]) // ✓ ["red", "green"]
96
+ *
97
+ * // No duplicates (default)
98
+ * const rolesSchema = manyOf(true, { values: ["admin", "editor", "viewer"] })
99
+ * rolesSchema.parse(["admin", "admin"]) // ✗ duplicate
100
+ *
101
+ * // Allow duplicates
102
+ * const itemsSchema = manyOf(true, {
103
+ * values: [1, 2, 3],
104
+ * allowDuplicates: true,
105
+ * })
106
+ * itemsSchema.parse([1, 1, 2]) // ✓ [1, 1, 2]
107
+ * ```
108
+ */
109
+ declare function manyOf<IsRequired extends boolean = false, const V extends readonly (string | number)[] = readonly (string | number)[]>(required?: IsRequired, options?: Omit<ManyOfOptions<IsRequired, V>, "required">): ManyOfSchema<IsRequired, V>;
110
+
111
+ export { type ManyOfMessages, type ManyOfOptions, type ManyOfSchema, manyOf };
@@ -0,0 +1,111 @@
1
+ import { ZodType } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ /**
5
+ * @fileoverview ManyOf validator for Zod Kit
6
+ *
7
+ * Provides multi-select validation that restricts input to an array of values
8
+ * from a predefined set, with min/max selection, duplicate control, and transformation.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.2.2
12
+ */
13
+
14
+ /**
15
+ * Type definition for manyOf validation error messages
16
+ *
17
+ * @interface ManyOfMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when a value is not in the allowed list
20
+ * @property {string} [minSelect] - Message when fewer than minimum items are selected
21
+ * @property {string} [maxSelect] - Message when more than maximum items are selected
22
+ * @property {string} [duplicate] - Message when duplicate values are found
23
+ */
24
+ type ManyOfMessages = {
25
+ required?: string;
26
+ invalid?: string;
27
+ minSelect?: string;
28
+ maxSelect?: string;
29
+ duplicate?: string;
30
+ };
31
+ /**
32
+ * Configuration options for manyOf validation
33
+ *
34
+ * @template IsRequired - Whether the field is required (affects return type)
35
+ * @template T - The type of allowed values
36
+ *
37
+ * @interface ManyOfOptions
38
+ * @property {T[]} values - Array of allowed values
39
+ * @property {T[] | null} [defaultValue] - Default value when input is empty
40
+ * @property {number} [min] - Minimum number of selections
41
+ * @property {number} [max] - Maximum number of selections
42
+ * @property {boolean} [allowDuplicates=false] - Whether to allow duplicate selections
43
+ * @property {boolean} [caseSensitive=true] - Whether string matching is case-sensitive
44
+ * @property {Function} [transform] - Custom transformation function applied to each value
45
+ * @property {Record<Locale, ManyOfMessages>} [i18n] - Custom error messages for different locales
46
+ */
47
+ type ManyOfOptions<IsRequired extends boolean = true, V extends readonly (string | number)[] = readonly (string | number)[]> = {
48
+ values: V;
49
+ defaultValue?: IsRequired extends true ? V[number][] : V[number][] | null;
50
+ min?: number;
51
+ max?: number;
52
+ allowDuplicates?: boolean;
53
+ caseSensitive?: boolean;
54
+ transform?: (value: V[number][]) => V[number][];
55
+ i18n?: Partial<Record<Locale, Partial<ManyOfMessages>>>;
56
+ };
57
+ /**
58
+ * Type alias for manyOf validation schema based on required flag
59
+ *
60
+ * @template IsRequired - Whether the field is required
61
+ * @template T - The type of allowed values
62
+ */
63
+ type ManyOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number][]> : ZodType<V[number][] | null>;
64
+ /**
65
+ * Creates a Zod schema for multi-select validation that restricts values to a predefined set
66
+ *
67
+ * @template IsRequired - Whether the field is required (affects return type)
68
+ * @template T - The type of allowed values (string | number)
69
+ * @param {IsRequired} [required=false] - Whether the field is required
70
+ * @param {ManyOfOptions<IsRequired, T>} options - Configuration options (values is required)
71
+ * @returns {ManyOfSchema<IsRequired, T>} Zod schema for manyOf validation
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * // Basic multi-select (optional by default)
76
+ * const tagsSchema = manyOf(false, { values: ["js", "ts", "rust", "go"] })
77
+ * tagsSchema.parse(["js", "ts"]) // ✓ ["js", "ts"]
78
+ * tagsSchema.parse(null) // ✓ null
79
+ *
80
+ * // Required with min/max
81
+ * const skillsSchema = manyOf(true, {
82
+ * values: ["react", "vue", "angular", "svelte"],
83
+ * min: 1,
84
+ * max: 3,
85
+ * })
86
+ * skillsSchema.parse(["react"]) // ✓
87
+ * skillsSchema.parse([]) // ✗ minSelect
88
+ * skillsSchema.parse(["react", "vue", "angular", "svelte"]) // ✗ maxSelect
89
+ *
90
+ * // Case-insensitive matching
91
+ * const colorsSchema = manyOf(true, {
92
+ * values: ["red", "green", "blue"],
93
+ * caseSensitive: false,
94
+ * })
95
+ * colorsSchema.parse(["RED", "Green"]) // ✓ ["red", "green"]
96
+ *
97
+ * // No duplicates (default)
98
+ * const rolesSchema = manyOf(true, { values: ["admin", "editor", "viewer"] })
99
+ * rolesSchema.parse(["admin", "admin"]) // ✗ duplicate
100
+ *
101
+ * // Allow duplicates
102
+ * const itemsSchema = manyOf(true, {
103
+ * values: [1, 2, 3],
104
+ * allowDuplicates: true,
105
+ * })
106
+ * itemsSchema.parse([1, 1, 2]) // ✓ [1, 1, 2]
107
+ * ```
108
+ */
109
+ declare function manyOf<IsRequired extends boolean = false, const V extends readonly (string | number)[] = readonly (string | number)[]>(required?: IsRequired, options?: Omit<ManyOfOptions<IsRequired, V>, "required">): ManyOfSchema<IsRequired, V>;
110
+
111
+ export { type ManyOfMessages, type ManyOfOptions, type ManyOfSchema, manyOf };
@@ -0,0 +1,7 @@
1
+ import {
2
+ manyOf
3
+ } from "../chunk-7X3XPK6A.js";
4
+ import "../chunk-POIDES2L.js";
5
+ export {
6
+ manyOf
7
+ };
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkEGHL277Kcjs = require('../chunk-EGHL277K.cjs');
4
- require('../chunk-UCOXAZJF.cjs');
3
+ var _chunkG747FHUZcjs = require('../chunk-G747FHUZ.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
5
 
6
6
 
7
- exports.number = _chunkEGHL277Kcjs.number;
7
+ exports.number = _chunkG747FHUZcjs.number;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  number
3
- } from "../chunk-FM3EZ72O.js";
4
- import "../chunk-6AAP4LPF.js";
3
+ } from "../chunk-3QLUXIY2.js";
4
+ import "../chunk-POIDES2L.js";
5
5
  export {
6
6
  number
7
7
  };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkFMPHW7IDcjs = require('../chunk-FMPHW7ID.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
+
6
+
7
+ exports.oneOf = _chunkFMPHW7IDcjs.oneOf;
@@ -0,0 +1,104 @@
1
+ import { ZodType } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.cjs';
3
+
4
+ /**
5
+ * @fileoverview OneOf validator for Zod Kit
6
+ *
7
+ * Provides single-select validation that restricts input to a predefined set of allowed values,
8
+ * with support for case-insensitive matching, default values, and transformation.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.2.2
12
+ */
13
+
14
+ /**
15
+ * Type definition for oneOf validation error messages
16
+ *
17
+ * @interface OneOfMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when value is not in the allowed list
20
+ */
21
+ type OneOfMessages = {
22
+ required?: string;
23
+ invalid?: string;
24
+ };
25
+ /**
26
+ * Configuration options for oneOf validation
27
+ *
28
+ * @template IsRequired - Whether the field is required (affects return type)
29
+ * @template T - The type of allowed values
30
+ *
31
+ * @interface OneOfOptions
32
+ * @property {T[]} values - Array of allowed values
33
+ * @property {T | null} [defaultValue] - Default value when input is empty
34
+ * @property {boolean} [caseSensitive=true] - Whether string matching is case-sensitive
35
+ * @property {Function} [transform] - Custom transformation function applied after validation
36
+ * @property {Record<Locale, OneOfMessages>} [i18n] - Custom error messages for different locales
37
+ */
38
+ type OneOfOptions<IsRequired extends boolean = true, V extends readonly (string | number)[] = readonly (string | number)[]> = {
39
+ values: V;
40
+ defaultValue?: IsRequired extends true ? V[number] : V[number] | null;
41
+ caseSensitive?: boolean;
42
+ transform?: (value: V[number]) => V[number];
43
+ i18n?: Partial<Record<Locale, Partial<OneOfMessages>>>;
44
+ };
45
+ /**
46
+ * Type alias for oneOf validation schema based on required flag
47
+ *
48
+ * @template IsRequired - Whether the field is required
49
+ * @template T - The type of allowed values
50
+ */
51
+ type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number]> : ZodType<V[number] | null>;
52
+ /**
53
+ * Creates a Zod schema for single-select validation that restricts values to a predefined set
54
+ *
55
+ * @template IsRequired - Whether the field is required (affects return type)
56
+ * @template T - The type of allowed values (string | number)
57
+ * @param {IsRequired} [required=false] - Whether the field is required
58
+ * @param {OneOfOptions<IsRequired, T>} options - Configuration options (values is required)
59
+ * @returns {OneOfSchema<IsRequired, T>} Zod schema for oneOf validation
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Basic single-select validation (optional by default)
64
+ * const roleSchema = oneOf(false, { values: ["admin", "editor", "viewer"] })
65
+ * roleSchema.parse("admin") // ✓ "admin"
66
+ * roleSchema.parse(null) // ✓ null
67
+ *
68
+ * // Required
69
+ * const statusSchema = oneOf(true, { values: ["active", "inactive", "pending"] })
70
+ * statusSchema.parse("active") // ✓ "active"
71
+ * statusSchema.parse(null) // ✗ Required
72
+ * statusSchema.parse("banned") // ✗ Invalid
73
+ *
74
+ * // Numeric values
75
+ * const prioritySchema = oneOf(true, { values: [1, 2, 3, 4, 5] })
76
+ * prioritySchema.parse(3) // ✓ 3
77
+ * prioritySchema.parse(10) // ✗ Invalid
78
+ *
79
+ * // Case-insensitive matching
80
+ * const colorSchema = oneOf(true, {
81
+ * values: ["red", "green", "blue"],
82
+ * caseSensitive: false
83
+ * })
84
+ * colorSchema.parse("RED") // ✓ "red" (normalized to match original)
85
+ * colorSchema.parse("Green") // ✓ "green"
86
+ *
87
+ * // With default value
88
+ * const tierSchema = oneOf(false, {
89
+ * values: ["free", "pro", "enterprise"],
90
+ * defaultValue: "free"
91
+ * })
92
+ * tierSchema.parse(null) // ✓ "free"
93
+ *
94
+ * // With transform
95
+ * const sizeSchema = oneOf(true, {
96
+ * values: ["s", "m", "l", "xl"],
97
+ * transform: (val) => val.toUpperCase() as any
98
+ * })
99
+ * sizeSchema.parse("m") // ✓ "M"
100
+ * ```
101
+ */
102
+ declare function oneOf<IsRequired extends boolean = false, const V extends readonly (string | number)[] = readonly (string | number)[]>(required?: IsRequired, options?: Omit<OneOfOptions<IsRequired, V>, "required">): OneOfSchema<IsRequired, V>;
103
+
104
+ export { type OneOfMessages, type OneOfOptions, type OneOfSchema, oneOf };
@@ -0,0 +1,104 @@
1
+ import { ZodType } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ /**
5
+ * @fileoverview OneOf validator for Zod Kit
6
+ *
7
+ * Provides single-select validation that restricts input to a predefined set of allowed values,
8
+ * with support for case-insensitive matching, default values, and transformation.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.2.2
12
+ */
13
+
14
+ /**
15
+ * Type definition for oneOf validation error messages
16
+ *
17
+ * @interface OneOfMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when value is not in the allowed list
20
+ */
21
+ type OneOfMessages = {
22
+ required?: string;
23
+ invalid?: string;
24
+ };
25
+ /**
26
+ * Configuration options for oneOf validation
27
+ *
28
+ * @template IsRequired - Whether the field is required (affects return type)
29
+ * @template T - The type of allowed values
30
+ *
31
+ * @interface OneOfOptions
32
+ * @property {T[]} values - Array of allowed values
33
+ * @property {T | null} [defaultValue] - Default value when input is empty
34
+ * @property {boolean} [caseSensitive=true] - Whether string matching is case-sensitive
35
+ * @property {Function} [transform] - Custom transformation function applied after validation
36
+ * @property {Record<Locale, OneOfMessages>} [i18n] - Custom error messages for different locales
37
+ */
38
+ type OneOfOptions<IsRequired extends boolean = true, V extends readonly (string | number)[] = readonly (string | number)[]> = {
39
+ values: V;
40
+ defaultValue?: IsRequired extends true ? V[number] : V[number] | null;
41
+ caseSensitive?: boolean;
42
+ transform?: (value: V[number]) => V[number];
43
+ i18n?: Partial<Record<Locale, Partial<OneOfMessages>>>;
44
+ };
45
+ /**
46
+ * Type alias for oneOf validation schema based on required flag
47
+ *
48
+ * @template IsRequired - Whether the field is required
49
+ * @template T - The type of allowed values
50
+ */
51
+ type OneOfSchema<IsRequired extends boolean, V extends readonly (string | number)[]> = IsRequired extends true ? ZodType<V[number]> : ZodType<V[number] | null>;
52
+ /**
53
+ * Creates a Zod schema for single-select validation that restricts values to a predefined set
54
+ *
55
+ * @template IsRequired - Whether the field is required (affects return type)
56
+ * @template T - The type of allowed values (string | number)
57
+ * @param {IsRequired} [required=false] - Whether the field is required
58
+ * @param {OneOfOptions<IsRequired, T>} options - Configuration options (values is required)
59
+ * @returns {OneOfSchema<IsRequired, T>} Zod schema for oneOf validation
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * // Basic single-select validation (optional by default)
64
+ * const roleSchema = oneOf(false, { values: ["admin", "editor", "viewer"] })
65
+ * roleSchema.parse("admin") // ✓ "admin"
66
+ * roleSchema.parse(null) // ✓ null
67
+ *
68
+ * // Required
69
+ * const statusSchema = oneOf(true, { values: ["active", "inactive", "pending"] })
70
+ * statusSchema.parse("active") // ✓ "active"
71
+ * statusSchema.parse(null) // ✗ Required
72
+ * statusSchema.parse("banned") // ✗ Invalid
73
+ *
74
+ * // Numeric values
75
+ * const prioritySchema = oneOf(true, { values: [1, 2, 3, 4, 5] })
76
+ * prioritySchema.parse(3) // ✓ 3
77
+ * prioritySchema.parse(10) // ✗ Invalid
78
+ *
79
+ * // Case-insensitive matching
80
+ * const colorSchema = oneOf(true, {
81
+ * values: ["red", "green", "blue"],
82
+ * caseSensitive: false
83
+ * })
84
+ * colorSchema.parse("RED") // ✓ "red" (normalized to match original)
85
+ * colorSchema.parse("Green") // ✓ "green"
86
+ *
87
+ * // With default value
88
+ * const tierSchema = oneOf(false, {
89
+ * values: ["free", "pro", "enterprise"],
90
+ * defaultValue: "free"
91
+ * })
92
+ * tierSchema.parse(null) // ✓ "free"
93
+ *
94
+ * // With transform
95
+ * const sizeSchema = oneOf(true, {
96
+ * values: ["s", "m", "l", "xl"],
97
+ * transform: (val) => val.toUpperCase() as any
98
+ * })
99
+ * sizeSchema.parse("m") // ✓ "M"
100
+ * ```
101
+ */
102
+ declare function oneOf<IsRequired extends boolean = false, const V extends readonly (string | number)[] = readonly (string | number)[]>(required?: IsRequired, options?: Omit<OneOfOptions<IsRequired, V>, "required">): OneOfSchema<IsRequired, V>;
103
+
104
+ export { type OneOfMessages, type OneOfOptions, type OneOfSchema, oneOf };
@@ -0,0 +1,7 @@
1
+ import {
2
+ oneOf
3
+ } from "../chunk-3ZF5JO3F.js";
4
+ import "../chunk-POIDES2L.js";
5
+ export {
6
+ oneOf
7
+ };
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkYPSEIDURcjs = require('../chunk-YPSEIDUR.cjs');
4
- require('../chunk-UCOXAZJF.cjs');
3
+ var _chunkQ24GYUTOcjs = require('../chunk-Q24GYUTO.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
5
 
6
6
 
7
- exports.password = _chunkYPSEIDURcjs.password;
7
+ exports.password = _chunkQ24GYUTOcjs.password;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  password
3
- } from "../chunk-46VAH2BJ.js";
4
- import "../chunk-6AAP4LPF.js";
3
+ } from "../chunk-NWQSOSNF.js";
4
+ import "../chunk-POIDES2L.js";
5
5
  export {
6
6
  password
7
7
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkORFHDJIIcjs = require('../chunk-ORFHDJII.cjs');
4
- require('../chunk-UCOXAZJF.cjs');
3
+ var _chunkHZ2WESSLcjs = require('../chunk-HZ2WESSL.cjs');
4
+ require('../chunk-Q7TUNJD4.cjs');
5
5
 
6
6
 
7
- exports.text = _chunkORFHDJIIcjs.text;
7
+ exports.text = _chunkHZ2WESSLcjs.text;
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  text
3
- } from "../chunk-K2UOY6TB.js";
4
- import "../chunk-6AAP4LPF.js";
3
+ } from "../chunk-T7PG4JDW.js";
4
+ import "../chunk-POIDES2L.js";
5
5
  export {
6
6
  text
7
7
  };