@hy_ong/zod-kit 0.2.0 → 0.2.2

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 (191) hide show
  1. package/.github/workflows/ci.yml +24 -0
  2. package/CLAUDE.md +64 -22
  3. package/dist/chunk-2SWEVDFZ.js +134 -0
  4. package/dist/chunk-32JI34CV.cjs +146 -0
  5. package/dist/chunk-42C5OHRK.js +71 -0
  6. package/dist/chunk-46VAH2BJ.js +160 -0
  7. package/dist/chunk-5JGTDL3Y.js +87 -0
  8. package/dist/chunk-5LEXCVLX.js +257 -0
  9. package/dist/chunk-6AAP4LPF.js +2606 -0
  10. package/dist/chunk-B4EZYZOK.cjs +215 -0
  11. package/dist/chunk-COYKBWTI.js +161 -0
  12. package/dist/chunk-DFJZ3NS2.cjs +151 -0
  13. package/dist/chunk-EDHT4LPO.js +118 -0
  14. package/dist/chunk-EGHL277K.cjs +165 -0
  15. package/dist/chunk-ERH4NIMU.cjs +69 -0
  16. package/dist/chunk-FM3EZ72O.js +165 -0
  17. package/dist/chunk-GJIRDBZJ.cjs +90 -0
  18. package/dist/chunk-H2XTEM4M.js +696 -0
  19. package/dist/chunk-HMSM6FFA.cjs +181 -0
  20. package/dist/chunk-HTEHINI7.cjs +177 -0
  21. package/dist/chunk-JOLSGZGN.cjs +696 -0
  22. package/dist/chunk-JXY7APBU.js +69 -0
  23. package/dist/chunk-K2UOY6TB.js +136 -0
  24. package/dist/chunk-KFOHKTFD.js +61 -0
  25. package/dist/chunk-L4HSIKTU.cjs +135 -0
  26. package/dist/chunk-LH7ZB4BK.js +124 -0
  27. package/dist/chunk-LL4ZWLGO.js +90 -0
  28. package/dist/chunk-M6MTP3NY.cjs +99 -0
  29. package/dist/chunk-MHJFYYGV.js +215 -0
  30. package/dist/chunk-MINMXGW3.js +135 -0
  31. package/dist/chunk-MM7IL2RG.js +181 -0
  32. package/dist/chunk-OPQJWHXN.cjs +301 -0
  33. package/dist/chunk-ORFHDJII.cjs +136 -0
  34. package/dist/chunk-ORVV4MCF.cjs +87 -0
  35. package/dist/chunk-QICQ6YEY.js +75 -0
  36. package/dist/chunk-RKUQREMW.js +127 -0
  37. package/dist/chunk-RO47DKQG.js +146 -0
  38. package/dist/chunk-RRPXIRTQ.cjs +257 -0
  39. package/dist/chunk-RYFG2GKM.cjs +118 -0
  40. package/dist/chunk-STNHTRG7.cjs +124 -0
  41. package/dist/chunk-TFGS34VD.cjs +71 -0
  42. package/dist/chunk-TQXDUMML.cjs +61 -0
  43. package/dist/chunk-UBK3VCVH.cjs +134 -0
  44. package/dist/chunk-UCOXAZJF.cjs +2606 -0
  45. package/dist/chunk-UQZKFAFX.js +130 -0
  46. package/dist/chunk-VB2KV2ZM.cjs +130 -0
  47. package/dist/chunk-WABKPFPK.js +151 -0
  48. package/dist/chunk-WDI4QJMQ.js +177 -0
  49. package/dist/chunk-YDH3L27K.cjs +127 -0
  50. package/dist/chunk-YIM3D2AD.js +99 -0
  51. package/dist/chunk-YPSEIDUR.cjs +160 -0
  52. package/dist/chunk-ZNJLWJX3.cjs +75 -0
  53. package/dist/chunk-ZTFCJCPO.cjs +161 -0
  54. package/dist/chunk-ZXUMK2RR.js +301 -0
  55. package/dist/common/boolean.cjs +7 -0
  56. package/dist/common/boolean.d.cts +119 -0
  57. package/dist/common/boolean.d.ts +119 -0
  58. package/dist/common/boolean.js +7 -0
  59. package/dist/common/color.cjs +9 -0
  60. package/dist/common/color.d.cts +26 -0
  61. package/dist/common/color.d.ts +26 -0
  62. package/dist/common/color.js +9 -0
  63. package/dist/common/coordinate.cjs +11 -0
  64. package/dist/common/coordinate.d.cts +23 -0
  65. package/dist/common/coordinate.d.ts +23 -0
  66. package/dist/common/coordinate.js +11 -0
  67. package/dist/common/credit-card.cjs +11 -0
  68. package/dist/common/credit-card.d.cts +22 -0
  69. package/dist/common/credit-card.d.ts +22 -0
  70. package/dist/common/credit-card.js +11 -0
  71. package/dist/common/date.cjs +7 -0
  72. package/dist/common/date.d.cts +174 -0
  73. package/dist/common/date.d.ts +174 -0
  74. package/dist/common/date.js +7 -0
  75. package/dist/common/datetime.cjs +15 -0
  76. package/dist/common/datetime.d.cts +301 -0
  77. package/dist/common/datetime.d.ts +301 -0
  78. package/dist/common/datetime.js +15 -0
  79. package/dist/common/email.cjs +7 -0
  80. package/dist/common/email.d.cts +149 -0
  81. package/dist/common/email.d.ts +149 -0
  82. package/dist/common/email.js +7 -0
  83. package/dist/common/file.cjs +7 -0
  84. package/dist/common/file.d.cts +178 -0
  85. package/dist/common/file.d.ts +178 -0
  86. package/dist/common/file.js +7 -0
  87. package/dist/common/id.cjs +13 -0
  88. package/dist/common/id.d.cts +288 -0
  89. package/dist/common/id.d.ts +288 -0
  90. package/dist/common/id.js +13 -0
  91. package/dist/common/ip.cjs +11 -0
  92. package/dist/common/ip.d.cts +25 -0
  93. package/dist/common/ip.d.ts +25 -0
  94. package/dist/common/ip.js +11 -0
  95. package/dist/common/number.cjs +7 -0
  96. package/dist/common/number.d.cts +167 -0
  97. package/dist/common/number.d.ts +167 -0
  98. package/dist/common/number.js +7 -0
  99. package/dist/common/password.cjs +7 -0
  100. package/dist/common/password.d.cts +192 -0
  101. package/dist/common/password.d.ts +192 -0
  102. package/dist/common/password.js +7 -0
  103. package/dist/common/text.cjs +7 -0
  104. package/dist/common/text.d.cts +156 -0
  105. package/dist/common/text.d.ts +156 -0
  106. package/dist/common/text.js +7 -0
  107. package/dist/common/time.cjs +15 -0
  108. package/dist/common/time.d.cts +268 -0
  109. package/dist/common/time.d.ts +268 -0
  110. package/dist/common/time.js +15 -0
  111. package/dist/common/url.cjs +7 -0
  112. package/dist/common/url.d.cts +196 -0
  113. package/dist/common/url.d.ts +196 -0
  114. package/dist/common/url.js +7 -0
  115. package/dist/config-CABSSvAp.d.cts +5 -0
  116. package/dist/config-CABSSvAp.d.ts +5 -0
  117. package/dist/index.cjs +180 -5255
  118. package/dist/index.d.cts +28 -3150
  119. package/dist/index.d.ts +28 -3150
  120. package/dist/index.js +135 -5131
  121. package/dist/taiwan/bank-account.cjs +11 -0
  122. package/dist/taiwan/bank-account.d.cts +22 -0
  123. package/dist/taiwan/bank-account.d.ts +22 -0
  124. package/dist/taiwan/bank-account.js +11 -0
  125. package/dist/taiwan/business-id.cjs +9 -0
  126. package/dist/taiwan/business-id.d.cts +133 -0
  127. package/dist/taiwan/business-id.d.ts +133 -0
  128. package/dist/taiwan/business-id.js +9 -0
  129. package/dist/taiwan/fax.cjs +9 -0
  130. package/dist/taiwan/fax.d.cts +157 -0
  131. package/dist/taiwan/fax.d.ts +157 -0
  132. package/dist/taiwan/fax.js +9 -0
  133. package/dist/taiwan/invoice.cjs +9 -0
  134. package/dist/taiwan/invoice.d.cts +17 -0
  135. package/dist/taiwan/invoice.d.ts +17 -0
  136. package/dist/taiwan/invoice.js +9 -0
  137. package/dist/taiwan/license-plate.cjs +9 -0
  138. package/dist/taiwan/license-plate.d.cts +19 -0
  139. package/dist/taiwan/license-plate.d.ts +19 -0
  140. package/dist/taiwan/license-plate.js +9 -0
  141. package/dist/taiwan/mobile.cjs +9 -0
  142. package/dist/taiwan/mobile.d.cts +146 -0
  143. package/dist/taiwan/mobile.d.ts +146 -0
  144. package/dist/taiwan/mobile.js +9 -0
  145. package/dist/taiwan/national-id.cjs +15 -0
  146. package/dist/taiwan/national-id.d.cts +214 -0
  147. package/dist/taiwan/national-id.d.ts +214 -0
  148. package/dist/taiwan/national-id.js +15 -0
  149. package/dist/taiwan/passport.cjs +9 -0
  150. package/dist/taiwan/passport.d.cts +19 -0
  151. package/dist/taiwan/passport.d.ts +19 -0
  152. package/dist/taiwan/passport.js +9 -0
  153. package/dist/taiwan/postal-code.cjs +17 -0
  154. package/dist/taiwan/postal-code.d.cts +237 -0
  155. package/dist/taiwan/postal-code.d.ts +237 -0
  156. package/dist/taiwan/postal-code.js +17 -0
  157. package/dist/taiwan/tel.cjs +9 -0
  158. package/dist/taiwan/tel.d.cts +162 -0
  159. package/dist/taiwan/tel.d.ts +162 -0
  160. package/dist/taiwan/tel.js +9 -0
  161. package/package.json +132 -6
  162. package/src/i18n/locales/en-GB.json +51 -0
  163. package/src/i18n/locales/en-US.json +52 -1
  164. package/src/i18n/locales/id-ID.json +51 -0
  165. package/src/i18n/locales/ja-JP.json +51 -0
  166. package/src/i18n/locales/ko-KR.json +51 -0
  167. package/src/i18n/locales/ms-MY.json +51 -0
  168. package/src/i18n/locales/th-TH.json +51 -0
  169. package/src/i18n/locales/vi-VN.json +51 -0
  170. package/src/i18n/locales/zh-CN.json +51 -0
  171. package/src/i18n/locales/zh-TW.json +51 -0
  172. package/src/index.ts +10 -2
  173. package/src/validators/common/color.ts +192 -0
  174. package/src/validators/common/coordinate.ts +159 -0
  175. package/src/validators/common/credit-card.ts +134 -0
  176. package/src/validators/common/id.ts +45 -3
  177. package/src/validators/common/ip.ts +210 -0
  178. package/src/validators/taiwan/bank-account.ts +176 -0
  179. package/src/validators/taiwan/invoice.ts +84 -0
  180. package/src/validators/taiwan/license-plate.ts +110 -0
  181. package/src/validators/taiwan/passport.ts +103 -0
  182. package/tests/common/color.test.ts +587 -0
  183. package/tests/common/coordinate.test.ts +345 -0
  184. package/tests/common/credit-card.test.ts +378 -0
  185. package/tests/common/id.test.ts +68 -3
  186. package/tests/common/ip.test.ts +419 -0
  187. package/tests/taiwan/bank-account.test.ts +286 -0
  188. package/tests/taiwan/invoice.test.ts +227 -0
  189. package/tests/taiwan/license-plate.test.ts +280 -0
  190. package/tests/taiwan/passport.test.ts +277 -0
  191. package/tsup.config.ts +36 -0
@@ -0,0 +1,23 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ type CoordinateType = "latitude" | "longitude" | "pair";
5
+ type CoordinateMessages = {
6
+ required?: string;
7
+ invalid?: string;
8
+ invalidLatitude?: string;
9
+ invalidLongitude?: string;
10
+ };
11
+ type CoordinateOptions<IsRequired extends boolean = true> = {
12
+ type?: CoordinateType;
13
+ precision?: number;
14
+ transform?: (value: string) => string;
15
+ defaultValue?: IsRequired extends true ? string : string | null;
16
+ i18n?: Partial<Record<Locale, Partial<CoordinateMessages>>>;
17
+ };
18
+ type CoordinateSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
19
+ declare function validateLatitude(value: number): boolean;
20
+ declare function validateLongitude(value: number): boolean;
21
+ declare function coordinate<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<CoordinateOptions<IsRequired>, "required">): CoordinateSchema<IsRequired>;
22
+
23
+ export { type CoordinateMessages, type CoordinateOptions, type CoordinateSchema, type CoordinateType, coordinate, validateLatitude, validateLongitude };
@@ -0,0 +1,11 @@
1
+ import {
2
+ coordinate,
3
+ validateLatitude,
4
+ validateLongitude
5
+ } from "../chunk-EDHT4LPO.js";
6
+ import "../chunk-6AAP4LPF.js";
7
+ export {
8
+ coordinate,
9
+ validateLatitude,
10
+ validateLongitude
11
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+ var _chunkM6MTP3NYcjs = require('../chunk-M6MTP3NY.cjs');
6
+ require('../chunk-UCOXAZJF.cjs');
7
+
8
+
9
+
10
+
11
+ exports.creditCard = _chunkM6MTP3NYcjs.creditCard; exports.detectCardType = _chunkM6MTP3NYcjs.detectCardType; exports.validateCreditCard = _chunkM6MTP3NYcjs.validateCreditCard;
@@ -0,0 +1,22 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.cjs';
3
+
4
+ type CreditCardType = "visa" | "mastercard" | "amex" | "jcb" | "discover" | "unionpay" | "any";
5
+ type CreditCardMessages = {
6
+ required?: string;
7
+ invalid?: string;
8
+ notInWhitelist?: string;
9
+ };
10
+ type CreditCardOptions<IsRequired extends boolean = true> = {
11
+ cardType?: CreditCardType | CreditCardType[];
12
+ whitelist?: string[];
13
+ transform?: (value: string) => string;
14
+ defaultValue?: IsRequired extends true ? string : string | null;
15
+ i18n?: Partial<Record<Locale, Partial<CreditCardMessages>>>;
16
+ };
17
+ type CreditCardSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
18
+ declare function detectCardType(value: string): CreditCardType;
19
+ declare function validateCreditCard(value: string): boolean;
20
+ declare function creditCard<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<CreditCardOptions<IsRequired>, "required">): CreditCardSchema<IsRequired>;
21
+
22
+ export { type CreditCardMessages, type CreditCardOptions, type CreditCardSchema, type CreditCardType, creditCard, detectCardType, validateCreditCard };
@@ -0,0 +1,22 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ type CreditCardType = "visa" | "mastercard" | "amex" | "jcb" | "discover" | "unionpay" | "any";
5
+ type CreditCardMessages = {
6
+ required?: string;
7
+ invalid?: string;
8
+ notInWhitelist?: string;
9
+ };
10
+ type CreditCardOptions<IsRequired extends boolean = true> = {
11
+ cardType?: CreditCardType | CreditCardType[];
12
+ whitelist?: string[];
13
+ transform?: (value: string) => string;
14
+ defaultValue?: IsRequired extends true ? string : string | null;
15
+ i18n?: Partial<Record<Locale, Partial<CreditCardMessages>>>;
16
+ };
17
+ type CreditCardSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
18
+ declare function detectCardType(value: string): CreditCardType;
19
+ declare function validateCreditCard(value: string): boolean;
20
+ declare function creditCard<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<CreditCardOptions<IsRequired>, "required">): CreditCardSchema<IsRequired>;
21
+
22
+ export { type CreditCardMessages, type CreditCardOptions, type CreditCardSchema, type CreditCardType, creditCard, detectCardType, validateCreditCard };
@@ -0,0 +1,11 @@
1
+ import {
2
+ creditCard,
3
+ detectCardType,
4
+ validateCreditCard
5
+ } from "../chunk-YIM3D2AD.js";
6
+ import "../chunk-6AAP4LPF.js";
7
+ export {
8
+ creditCard,
9
+ detectCardType,
10
+ validateCreditCard
11
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkSTNHTRG7cjs = require('../chunk-STNHTRG7.cjs');
4
+ require('../chunk-UCOXAZJF.cjs');
5
+
6
+
7
+ exports.date = _chunkSTNHTRG7cjs.date;
@@ -0,0 +1,174 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.cjs';
3
+
4
+ /**
5
+ * @fileoverview Date validator for Zod Kit
6
+ *
7
+ * Provides comprehensive date validation with format support, range validation,
8
+ * temporal constraints, and weekday/weekend filtering using dayjs library.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.0.5
12
+ */
13
+
14
+ /**
15
+ * Type definition for date validation error messages
16
+ *
17
+ * @interface DateMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when date is invalid
20
+ * @property {string} [format] - Message when date doesn't match expected format
21
+ * @property {string} [min] - Message when date is before minimum allowed
22
+ * @property {string} [max] - Message when date is after maximum allowed
23
+ * @property {string} [includes] - Message when date string doesn't contain required text
24
+ * @property {string} [excludes] - Message when date string contains forbidden text
25
+ * @property {string} [past] - Message when date must be in the past
26
+ * @property {string} [future] - Message when date must be in the future
27
+ * @property {string} [today] - Message when date must be today
28
+ * @property {string} [notToday] - Message when date must not be today
29
+ * @property {string} [weekday] - Message when date must be a weekday
30
+ * @property {string} [notWeekday] - Message when date must not be a weekday
31
+ * @property {string} [weekend] - Message when date must be a weekend
32
+ * @property {string} [notWeekend] - Message when date must not be a weekend
33
+ */
34
+ type DateMessages = {
35
+ required?: string;
36
+ invalid?: string;
37
+ format?: string;
38
+ min?: string;
39
+ max?: string;
40
+ includes?: string;
41
+ excludes?: string;
42
+ past?: string;
43
+ future?: string;
44
+ today?: string;
45
+ notToday?: string;
46
+ weekday?: string;
47
+ notWeekday?: string;
48
+ weekend?: string;
49
+ notWeekend?: string;
50
+ };
51
+ /**
52
+ * Configuration options for date validation
53
+ *
54
+ * @template IsRequired - Whether the field is required (affects return type)
55
+ *
56
+ * @interface DateOptions
57
+ * @property {IsRequired} [required=true] - Whether the field is required
58
+ * @property {string} [min] - Minimum allowed date (in same format as specified)
59
+ * @property {string} [max] - Maximum allowed date (in same format as specified)
60
+ * @property {string} [format="YYYY-MM-DD"] - Date format for parsing and validation
61
+ * @property {string} [includes] - String that must be included in the date
62
+ * @property {string | string[]} [excludes] - String(s) that must not be included
63
+ * @property {boolean} [mustBePast] - Whether date must be in the past
64
+ * @property {boolean} [mustBeFuture] - Whether date must be in the future
65
+ * @property {boolean} [mustBeToday] - Whether date must be today
66
+ * @property {boolean} [mustNotBeToday] - Whether date must not be today
67
+ * @property {boolean} [weekdaysOnly] - Whether date must be a weekday (Monday-Friday)
68
+ * @property {boolean} [weekendsOnly] - Whether date must be a weekend (Saturday-Sunday)
69
+ * @property {Function} [transform] - Custom transformation function for date strings
70
+ * @property {string | null} [defaultValue] - Default value when input is empty
71
+ * @property {Record<Locale, DateMessages>} [i18n] - Custom error messages for different locales
72
+ */
73
+ type DateOptions<IsRequired extends boolean = true> = {
74
+ min?: string;
75
+ max?: string;
76
+ format?: string;
77
+ includes?: string;
78
+ excludes?: string | string[];
79
+ mustBePast?: boolean;
80
+ mustBeFuture?: boolean;
81
+ mustBeToday?: boolean;
82
+ mustNotBeToday?: boolean;
83
+ weekdaysOnly?: boolean;
84
+ weekendsOnly?: boolean;
85
+ transform?: (value: string) => string;
86
+ defaultValue?: IsRequired extends true ? string : string | null;
87
+ i18n?: Partial<Record<Locale, Partial<DateMessages>>>;
88
+ };
89
+ /**
90
+ * Type alias for date validation schema based on required flag
91
+ *
92
+ * @template IsRequired - Whether the field is required
93
+ * @typedef DateSchema
94
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
95
+ */
96
+ type DateSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
97
+ /**
98
+ * Creates a Zod schema for date validation with temporal constraints
99
+ *
100
+ * @template IsRequired - Whether the field is required (affects return type)
101
+ * @param {IsRequired} [required=false] - Whether the field is required
102
+ * @param {Omit<ValidatorOptions<IsRequired>, 'required'>} [options] - Configuration options for validation
103
+ * @returns {DateSchema<IsRequired>} Zod schema for date validation
104
+ *
105
+ * @description
106
+ * Creates a comprehensive date validator with format support, range validation,
107
+ * temporal constraints, and weekday/weekend filtering using dayjs library.
108
+ *
109
+ * Features:
110
+ * - Flexible date format parsing (default: YYYY-MM-DD)
111
+ * - Range validation (min/max dates)
112
+ * - Temporal validation (past/future/today)
113
+ * - Weekday/weekend filtering
114
+ * - Content inclusion/exclusion
115
+ * - Custom transformation functions
116
+ * - Comprehensive internationalization
117
+ * - Strict date parsing with format validation
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * // Basic date validation (YYYY-MM-DD)
122
+ * const basicSchema = date()
123
+ * basicSchema.parse("2024-03-15") // ✓ Valid
124
+ * basicSchema.parse(null) // ✓ Valid (optional)
125
+ *
126
+ * // Required validation
127
+ * const requiredSchema = parse("2024-03-15") // ✓ Valid
128
+ (true)
129
+ * requiredSchema.parse(null) // ✗ Invalid (required)
130
+ *
131
+ * basicSchema.parse("2024-13-01") // ✗ Invalid (month 13)
132
+ *
133
+ * // Custom format
134
+ * const customFormatSchema = date(false, { format: "DD/MM/YYYY" })
135
+ * customFormatSchema.parse("15/03/2024") // ✓ Valid
136
+ * customFormatSchema.parse("2024-03-15") // ✗ Invalid (wrong format)
137
+ *
138
+ * // Date range validation
139
+ * const rangeSchema = date(false, {
140
+ * min: "2024-01-01",
141
+ * max: "2024-12-31"
142
+ * })
143
+ * rangeSchema.parse("2024-06-15") // ✓ Valid
144
+ * rangeSchema.parse("2023-12-31") // ✗ Invalid (before min)
145
+ *
146
+ * // Future dates only
147
+ * const futureSchema = date(false, { mustBeFuture: true })
148
+ * futureSchema.parse("2030-01-01") // ✓ Valid (assuming current date < 2030)
149
+ * futureSchema.parse("2020-01-01") // ✗ Invalid (past date)
150
+ *
151
+ * // Weekdays only (Monday-Friday)
152
+ * const weekdaySchema = date(false, { weekdaysOnly: true })
153
+ * weekdaySchema.parse("2024-03-15") // ✓ Valid (if Friday)
154
+ * weekdaySchema.parse("2024-03-16") // ✗ Invalid (if Saturday)
155
+ *
156
+ * // Business date validation
157
+ * const businessSchema = date(false, {
158
+ * format: "YYYY-MM-DD",
159
+ * mustBeFuture: true,
160
+ * weekdaysOnly: true
161
+ * })
162
+ *
163
+ * // Optional with default
164
+ * const optionalSchema = date(false, {
165
+ * defaultValue: "2024-01-01"
166
+ * })
167
+ * ```
168
+ *
169
+ * @throws {z.ZodError} When validation fails with specific error messages
170
+ * @see {@link DateOptions} for all available configuration options
171
+ */
172
+ declare function date<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<DateOptions<IsRequired>, 'required'>): DateSchema<IsRequired>;
173
+
174
+ export { type DateMessages, type DateOptions, type DateSchema, date };
@@ -0,0 +1,174 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ /**
5
+ * @fileoverview Date validator for Zod Kit
6
+ *
7
+ * Provides comprehensive date validation with format support, range validation,
8
+ * temporal constraints, and weekday/weekend filtering using dayjs library.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.0.5
12
+ */
13
+
14
+ /**
15
+ * Type definition for date validation error messages
16
+ *
17
+ * @interface DateMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when date is invalid
20
+ * @property {string} [format] - Message when date doesn't match expected format
21
+ * @property {string} [min] - Message when date is before minimum allowed
22
+ * @property {string} [max] - Message when date is after maximum allowed
23
+ * @property {string} [includes] - Message when date string doesn't contain required text
24
+ * @property {string} [excludes] - Message when date string contains forbidden text
25
+ * @property {string} [past] - Message when date must be in the past
26
+ * @property {string} [future] - Message when date must be in the future
27
+ * @property {string} [today] - Message when date must be today
28
+ * @property {string} [notToday] - Message when date must not be today
29
+ * @property {string} [weekday] - Message when date must be a weekday
30
+ * @property {string} [notWeekday] - Message when date must not be a weekday
31
+ * @property {string} [weekend] - Message when date must be a weekend
32
+ * @property {string} [notWeekend] - Message when date must not be a weekend
33
+ */
34
+ type DateMessages = {
35
+ required?: string;
36
+ invalid?: string;
37
+ format?: string;
38
+ min?: string;
39
+ max?: string;
40
+ includes?: string;
41
+ excludes?: string;
42
+ past?: string;
43
+ future?: string;
44
+ today?: string;
45
+ notToday?: string;
46
+ weekday?: string;
47
+ notWeekday?: string;
48
+ weekend?: string;
49
+ notWeekend?: string;
50
+ };
51
+ /**
52
+ * Configuration options for date validation
53
+ *
54
+ * @template IsRequired - Whether the field is required (affects return type)
55
+ *
56
+ * @interface DateOptions
57
+ * @property {IsRequired} [required=true] - Whether the field is required
58
+ * @property {string} [min] - Minimum allowed date (in same format as specified)
59
+ * @property {string} [max] - Maximum allowed date (in same format as specified)
60
+ * @property {string} [format="YYYY-MM-DD"] - Date format for parsing and validation
61
+ * @property {string} [includes] - String that must be included in the date
62
+ * @property {string | string[]} [excludes] - String(s) that must not be included
63
+ * @property {boolean} [mustBePast] - Whether date must be in the past
64
+ * @property {boolean} [mustBeFuture] - Whether date must be in the future
65
+ * @property {boolean} [mustBeToday] - Whether date must be today
66
+ * @property {boolean} [mustNotBeToday] - Whether date must not be today
67
+ * @property {boolean} [weekdaysOnly] - Whether date must be a weekday (Monday-Friday)
68
+ * @property {boolean} [weekendsOnly] - Whether date must be a weekend (Saturday-Sunday)
69
+ * @property {Function} [transform] - Custom transformation function for date strings
70
+ * @property {string | null} [defaultValue] - Default value when input is empty
71
+ * @property {Record<Locale, DateMessages>} [i18n] - Custom error messages for different locales
72
+ */
73
+ type DateOptions<IsRequired extends boolean = true> = {
74
+ min?: string;
75
+ max?: string;
76
+ format?: string;
77
+ includes?: string;
78
+ excludes?: string | string[];
79
+ mustBePast?: boolean;
80
+ mustBeFuture?: boolean;
81
+ mustBeToday?: boolean;
82
+ mustNotBeToday?: boolean;
83
+ weekdaysOnly?: boolean;
84
+ weekendsOnly?: boolean;
85
+ transform?: (value: string) => string;
86
+ defaultValue?: IsRequired extends true ? string : string | null;
87
+ i18n?: Partial<Record<Locale, Partial<DateMessages>>>;
88
+ };
89
+ /**
90
+ * Type alias for date validation schema based on required flag
91
+ *
92
+ * @template IsRequired - Whether the field is required
93
+ * @typedef DateSchema
94
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
95
+ */
96
+ type DateSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
97
+ /**
98
+ * Creates a Zod schema for date validation with temporal constraints
99
+ *
100
+ * @template IsRequired - Whether the field is required (affects return type)
101
+ * @param {IsRequired} [required=false] - Whether the field is required
102
+ * @param {Omit<ValidatorOptions<IsRequired>, 'required'>} [options] - Configuration options for validation
103
+ * @returns {DateSchema<IsRequired>} Zod schema for date validation
104
+ *
105
+ * @description
106
+ * Creates a comprehensive date validator with format support, range validation,
107
+ * temporal constraints, and weekday/weekend filtering using dayjs library.
108
+ *
109
+ * Features:
110
+ * - Flexible date format parsing (default: YYYY-MM-DD)
111
+ * - Range validation (min/max dates)
112
+ * - Temporal validation (past/future/today)
113
+ * - Weekday/weekend filtering
114
+ * - Content inclusion/exclusion
115
+ * - Custom transformation functions
116
+ * - Comprehensive internationalization
117
+ * - Strict date parsing with format validation
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * // Basic date validation (YYYY-MM-DD)
122
+ * const basicSchema = date()
123
+ * basicSchema.parse("2024-03-15") // ✓ Valid
124
+ * basicSchema.parse(null) // ✓ Valid (optional)
125
+ *
126
+ * // Required validation
127
+ * const requiredSchema = parse("2024-03-15") // ✓ Valid
128
+ (true)
129
+ * requiredSchema.parse(null) // ✗ Invalid (required)
130
+ *
131
+ * basicSchema.parse("2024-13-01") // ✗ Invalid (month 13)
132
+ *
133
+ * // Custom format
134
+ * const customFormatSchema = date(false, { format: "DD/MM/YYYY" })
135
+ * customFormatSchema.parse("15/03/2024") // ✓ Valid
136
+ * customFormatSchema.parse("2024-03-15") // ✗ Invalid (wrong format)
137
+ *
138
+ * // Date range validation
139
+ * const rangeSchema = date(false, {
140
+ * min: "2024-01-01",
141
+ * max: "2024-12-31"
142
+ * })
143
+ * rangeSchema.parse("2024-06-15") // ✓ Valid
144
+ * rangeSchema.parse("2023-12-31") // ✗ Invalid (before min)
145
+ *
146
+ * // Future dates only
147
+ * const futureSchema = date(false, { mustBeFuture: true })
148
+ * futureSchema.parse("2030-01-01") // ✓ Valid (assuming current date < 2030)
149
+ * futureSchema.parse("2020-01-01") // ✗ Invalid (past date)
150
+ *
151
+ * // Weekdays only (Monday-Friday)
152
+ * const weekdaySchema = date(false, { weekdaysOnly: true })
153
+ * weekdaySchema.parse("2024-03-15") // ✓ Valid (if Friday)
154
+ * weekdaySchema.parse("2024-03-16") // ✗ Invalid (if Saturday)
155
+ *
156
+ * // Business date validation
157
+ * const businessSchema = date(false, {
158
+ * format: "YYYY-MM-DD",
159
+ * mustBeFuture: true,
160
+ * weekdaysOnly: true
161
+ * })
162
+ *
163
+ * // Optional with default
164
+ * const optionalSchema = date(false, {
165
+ * defaultValue: "2024-01-01"
166
+ * })
167
+ * ```
168
+ *
169
+ * @throws {z.ZodError} When validation fails with specific error messages
170
+ * @see {@link DateOptions} for all available configuration options
171
+ */
172
+ declare function date<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<DateOptions<IsRequired>, 'required'>): DateSchema<IsRequired>;
173
+
174
+ export { type DateMessages, type DateOptions, type DateSchema, date };
@@ -0,0 +1,7 @@
1
+ import {
2
+ date
3
+ } from "../chunk-LH7ZB4BK.js";
4
+ import "../chunk-6AAP4LPF.js";
5
+ export {
6
+ date
7
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+
7
+ var _chunkOPQJWHXNcjs = require('../chunk-OPQJWHXN.cjs');
8
+ require('../chunk-UCOXAZJF.cjs');
9
+
10
+
11
+
12
+
13
+
14
+
15
+ exports.DATETIME_PATTERNS = _chunkOPQJWHXNcjs.DATETIME_PATTERNS; exports.datetime = _chunkOPQJWHXNcjs.datetime; exports.normalizeDateTimeValue = _chunkOPQJWHXNcjs.normalizeDateTimeValue; exports.parseDateTimeValue = _chunkOPQJWHXNcjs.parseDateTimeValue; exports.validateDateTimeFormat = _chunkOPQJWHXNcjs.validateDateTimeFormat;