@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,149 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.cjs';
3
+
4
+ /**
5
+ * @fileoverview Email validator for Zod Kit
6
+ *
7
+ * Provides comprehensive email validation with domain filtering, business email
8
+ * validation, disposable email detection, and extensive customization options.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.0.5
12
+ */
13
+
14
+ /**
15
+ * Type definition for email validation error messages
16
+ *
17
+ * @interface EmailMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when email format is invalid
20
+ * @property {string} [minLength] - Message when email is too short
21
+ * @property {string} [maxLength] - Message when email is too long
22
+ * @property {string} [includes] - Message when email doesn't contain required string
23
+ * @property {string} [domain] - Message when email domain is not allowed
24
+ * @property {string} [domainBlacklist] - Message when email domain is blacklisted
25
+ * @property {string} [businessOnly] - Message when free email providers are not allowed
26
+ * @property {string} [noDisposable] - Message when disposable email addresses are not allowed
27
+ */
28
+ type EmailMessages = {
29
+ required?: string;
30
+ invalid?: string;
31
+ minLength?: string;
32
+ maxLength?: string;
33
+ includes?: string;
34
+ domain?: string;
35
+ domainBlacklist?: string;
36
+ businessOnly?: string;
37
+ noDisposable?: string;
38
+ };
39
+ /**
40
+ * Configuration options for email validation
41
+ *
42
+ * @template IsRequired - Whether the field is required (affects return type)
43
+ *
44
+ * @interface EmailOptions
45
+ * @property {string | string[]} [domain] - Allowed domain(s) for email addresses
46
+ * @property {string[]} [domainBlacklist] - Domains that are not allowed
47
+ * @property {number} [minLength] - Minimum length of email address
48
+ * @property {number} [maxLength] - Maximum length of email address
49
+ * @property {string} [includes] - String that must be included in the email
50
+ * @property {string | string[]} [excludes] - String(s) that must not be included
51
+ * @property {boolean} [allowSubdomains=true] - Whether to allow subdomains in domain validation
52
+ * @property {boolean} [businessOnly=false] - If true, reject common free email providers
53
+ * @property {boolean} [noDisposable=false] - If true, reject disposable email addresses
54
+ * @property {boolean} [lowercase=true] - Whether to convert email to lowercase
55
+ * @property {Function} [transform] - Custom transformation function for email strings
56
+ * @property {string | null} [defaultValue] - Default value when input is empty
57
+ * @property {Record<Locale, EmailMessages>} [i18n] - Custom error messages for different locales
58
+ */
59
+ type EmailOptions<IsRequired extends boolean = true> = {
60
+ domain?: string | string[];
61
+ domainBlacklist?: string[];
62
+ minLength?: number;
63
+ maxLength?: number;
64
+ includes?: string;
65
+ excludes?: string | string[];
66
+ allowSubdomains?: boolean;
67
+ businessOnly?: boolean;
68
+ noDisposable?: boolean;
69
+ lowercase?: boolean;
70
+ transform?: (value: string) => string;
71
+ defaultValue?: IsRequired extends true ? string : string | null;
72
+ i18n?: Partial<Record<Locale, Partial<EmailMessages>>>;
73
+ };
74
+ /**
75
+ * Type alias for email validation schema based on required flag
76
+ *
77
+ * @template IsRequired - Whether the field is required
78
+ * @typedef EmailSchema
79
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
80
+ */
81
+ type EmailSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
82
+ /**
83
+ * Creates a Zod schema for email validation with comprehensive filtering options
84
+ *
85
+ * @template IsRequired - Whether the field is required (affects return type)
86
+ * @param {IsRequired} [required=false] - Whether the field is required
87
+ * @param {Omit<EmailOptions<IsRequired>, 'required'>} [options] - Configuration options for email validation
88
+ * @returns {EmailSchema<IsRequired>} Zod schema for email validation
89
+ *
90
+ * @description
91
+ * Creates a comprehensive email validator with domain filtering, business email
92
+ * validation, disposable email detection, and extensive customization options.
93
+ *
94
+ * Features:
95
+ * - RFC-compliant email format validation
96
+ * - Domain whitelist/blacklist support
97
+ * - Business email validation (excludes free providers)
98
+ * - Disposable email detection
99
+ * - Subdomain support configuration
100
+ * - Length validation
101
+ * - Content inclusion/exclusion
102
+ * - Automatic lowercase conversion
103
+ * - Custom transformation functions
104
+ * - Comprehensive internationalization
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Basic email validation (optional by default)
109
+ * const basicSchema = email()
110
+ * basicSchema.parse("user@example.com") // ✓ Valid
111
+ * basicSchema.parse(null) // ✓ Valid (optional)
112
+ *
113
+ * // Required email
114
+ * const requiredSchema = email(true)
115
+ * requiredSchema.parse("user@example.com") // ✓ Valid
116
+ * requiredSchema.parse(null) // ✗ Invalid (required)
117
+ *
118
+ * // Domain restriction
119
+ * const domainSchema = email(false, {
120
+ * domain: ["company.com", "organization.org"]
121
+ * })
122
+ * domainSchema.parse("user@company.com") // ✓ Valid
123
+ * domainSchema.parse("user@gmail.com") // ✗ Invalid
124
+ *
125
+ * // Business emails only (no free providers)
126
+ * const businessSchema = email(true, { businessOnly: true })
127
+ * businessSchema.parse("user@company.com") // ✓ Valid
128
+ * businessSchema.parse("user@gmail.com") // ✗ Invalid
129
+ *
130
+ * // No disposable emails
131
+ * const noDisposableSchema = email(true, { noDisposable: true })
132
+ * noDisposableSchema.parse("user@company.com") // ✓ Valid
133
+ * noDisposableSchema.parse("user@10minutemail.com") // ✗ Invalid
134
+ *
135
+ * // Domain blacklist
136
+ * const blacklistSchema = email(false, {
137
+ * domainBlacklist: ["spam.com", "blocked.org"]
138
+ * })
139
+ *
140
+ * // Optional with default
141
+ * const optionalSchema = email(false, { defaultValue: null })
142
+ * ```
143
+ *
144
+ * @throws {z.ZodError} When validation fails with specific error messages
145
+ * @see {@link EmailOptions} for all available configuration options
146
+ */
147
+ declare function email<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<EmailOptions<IsRequired>, 'required'>): EmailSchema<IsRequired>;
148
+
149
+ export { type EmailMessages, type EmailOptions, type EmailSchema, email };
@@ -0,0 +1,149 @@
1
+ import { ZodString, ZodNullable } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ /**
5
+ * @fileoverview Email validator for Zod Kit
6
+ *
7
+ * Provides comprehensive email validation with domain filtering, business email
8
+ * validation, disposable email detection, and extensive customization options.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.0.5
12
+ */
13
+
14
+ /**
15
+ * Type definition for email validation error messages
16
+ *
17
+ * @interface EmailMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when email format is invalid
20
+ * @property {string} [minLength] - Message when email is too short
21
+ * @property {string} [maxLength] - Message when email is too long
22
+ * @property {string} [includes] - Message when email doesn't contain required string
23
+ * @property {string} [domain] - Message when email domain is not allowed
24
+ * @property {string} [domainBlacklist] - Message when email domain is blacklisted
25
+ * @property {string} [businessOnly] - Message when free email providers are not allowed
26
+ * @property {string} [noDisposable] - Message when disposable email addresses are not allowed
27
+ */
28
+ type EmailMessages = {
29
+ required?: string;
30
+ invalid?: string;
31
+ minLength?: string;
32
+ maxLength?: string;
33
+ includes?: string;
34
+ domain?: string;
35
+ domainBlacklist?: string;
36
+ businessOnly?: string;
37
+ noDisposable?: string;
38
+ };
39
+ /**
40
+ * Configuration options for email validation
41
+ *
42
+ * @template IsRequired - Whether the field is required (affects return type)
43
+ *
44
+ * @interface EmailOptions
45
+ * @property {string | string[]} [domain] - Allowed domain(s) for email addresses
46
+ * @property {string[]} [domainBlacklist] - Domains that are not allowed
47
+ * @property {number} [minLength] - Minimum length of email address
48
+ * @property {number} [maxLength] - Maximum length of email address
49
+ * @property {string} [includes] - String that must be included in the email
50
+ * @property {string | string[]} [excludes] - String(s) that must not be included
51
+ * @property {boolean} [allowSubdomains=true] - Whether to allow subdomains in domain validation
52
+ * @property {boolean} [businessOnly=false] - If true, reject common free email providers
53
+ * @property {boolean} [noDisposable=false] - If true, reject disposable email addresses
54
+ * @property {boolean} [lowercase=true] - Whether to convert email to lowercase
55
+ * @property {Function} [transform] - Custom transformation function for email strings
56
+ * @property {string | null} [defaultValue] - Default value when input is empty
57
+ * @property {Record<Locale, EmailMessages>} [i18n] - Custom error messages for different locales
58
+ */
59
+ type EmailOptions<IsRequired extends boolean = true> = {
60
+ domain?: string | string[];
61
+ domainBlacklist?: string[];
62
+ minLength?: number;
63
+ maxLength?: number;
64
+ includes?: string;
65
+ excludes?: string | string[];
66
+ allowSubdomains?: boolean;
67
+ businessOnly?: boolean;
68
+ noDisposable?: boolean;
69
+ lowercase?: boolean;
70
+ transform?: (value: string) => string;
71
+ defaultValue?: IsRequired extends true ? string : string | null;
72
+ i18n?: Partial<Record<Locale, Partial<EmailMessages>>>;
73
+ };
74
+ /**
75
+ * Type alias for email validation schema based on required flag
76
+ *
77
+ * @template IsRequired - Whether the field is required
78
+ * @typedef EmailSchema
79
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
80
+ */
81
+ type EmailSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
82
+ /**
83
+ * Creates a Zod schema for email validation with comprehensive filtering options
84
+ *
85
+ * @template IsRequired - Whether the field is required (affects return type)
86
+ * @param {IsRequired} [required=false] - Whether the field is required
87
+ * @param {Omit<EmailOptions<IsRequired>, 'required'>} [options] - Configuration options for email validation
88
+ * @returns {EmailSchema<IsRequired>} Zod schema for email validation
89
+ *
90
+ * @description
91
+ * Creates a comprehensive email validator with domain filtering, business email
92
+ * validation, disposable email detection, and extensive customization options.
93
+ *
94
+ * Features:
95
+ * - RFC-compliant email format validation
96
+ * - Domain whitelist/blacklist support
97
+ * - Business email validation (excludes free providers)
98
+ * - Disposable email detection
99
+ * - Subdomain support configuration
100
+ * - Length validation
101
+ * - Content inclusion/exclusion
102
+ * - Automatic lowercase conversion
103
+ * - Custom transformation functions
104
+ * - Comprehensive internationalization
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * // Basic email validation (optional by default)
109
+ * const basicSchema = email()
110
+ * basicSchema.parse("user@example.com") // ✓ Valid
111
+ * basicSchema.parse(null) // ✓ Valid (optional)
112
+ *
113
+ * // Required email
114
+ * const requiredSchema = email(true)
115
+ * requiredSchema.parse("user@example.com") // ✓ Valid
116
+ * requiredSchema.parse(null) // ✗ Invalid (required)
117
+ *
118
+ * // Domain restriction
119
+ * const domainSchema = email(false, {
120
+ * domain: ["company.com", "organization.org"]
121
+ * })
122
+ * domainSchema.parse("user@company.com") // ✓ Valid
123
+ * domainSchema.parse("user@gmail.com") // ✗ Invalid
124
+ *
125
+ * // Business emails only (no free providers)
126
+ * const businessSchema = email(true, { businessOnly: true })
127
+ * businessSchema.parse("user@company.com") // ✓ Valid
128
+ * businessSchema.parse("user@gmail.com") // ✗ Invalid
129
+ *
130
+ * // No disposable emails
131
+ * const noDisposableSchema = email(true, { noDisposable: true })
132
+ * noDisposableSchema.parse("user@company.com") // ✓ Valid
133
+ * noDisposableSchema.parse("user@10minutemail.com") // ✗ Invalid
134
+ *
135
+ * // Domain blacklist
136
+ * const blacklistSchema = email(false, {
137
+ * domainBlacklist: ["spam.com", "blocked.org"]
138
+ * })
139
+ *
140
+ * // Optional with default
141
+ * const optionalSchema = email(false, { defaultValue: null })
142
+ * ```
143
+ *
144
+ * @throws {z.ZodError} When validation fails with specific error messages
145
+ * @see {@link EmailOptions} for all available configuration options
146
+ */
147
+ declare function email<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<EmailOptions<IsRequired>, 'required'>): EmailSchema<IsRequired>;
148
+
149
+ export { type EmailMessages, type EmailOptions, type EmailSchema, email };
@@ -0,0 +1,7 @@
1
+ import {
2
+ email
3
+ } from "../chunk-MM7IL2RG.js";
4
+ import "../chunk-6AAP4LPF.js";
5
+ export {
6
+ email
7
+ };
@@ -0,0 +1,7 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunkHTEHINI7cjs = require('../chunk-HTEHINI7.cjs');
4
+ require('../chunk-UCOXAZJF.cjs');
5
+
6
+
7
+ exports.file = _chunkHTEHINI7cjs.file;
@@ -0,0 +1,178 @@
1
+ import { ZodType } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.cjs';
3
+
4
+ /**
5
+ * @fileoverview File validator for Zod Kit
6
+ *
7
+ * Provides comprehensive file validation with MIME type filtering, size validation,
8
+ * extension validation, and extensive customization options.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.0.5
12
+ */
13
+
14
+ /**
15
+ * Type definition for file validation error messages
16
+ *
17
+ * @interface FileMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when file format is invalid
20
+ * @property {string} [size] - Message when file size exceeds limit
21
+ * @property {string} [minSize] - Message when file size is too small
22
+ * @property {string} [maxSize] - Message when file size exceeds maximum
23
+ * @property {string} [type] - Message when file type is not allowed
24
+ * @property {string} [extension] - Message when file extension is not allowed
25
+ * @property {string} [extensionBlacklist] - Message when file extension is blacklisted
26
+ * @property {string} [name] - Message when file name doesn't match pattern
27
+ * @property {string} [nameBlacklist] - Message when file name matches blacklisted pattern
28
+ * @property {string} [imageOnly] - Message when only image files are allowed
29
+ * @property {string} [documentOnly] - Message when only document files are allowed
30
+ * @property {string} [videoOnly] - Message when only video files are allowed
31
+ * @property {string} [audioOnly] - Message when only audio files are allowed
32
+ * @property {string} [archiveOnly] - Message when only archive files are allowed
33
+ */
34
+ type FileMessages = {
35
+ required?: string;
36
+ invalid?: string;
37
+ size?: string;
38
+ minSize?: string;
39
+ maxSize?: string;
40
+ type?: string;
41
+ extension?: string;
42
+ extensionBlacklist?: string;
43
+ name?: string;
44
+ nameBlacklist?: string;
45
+ imageOnly?: string;
46
+ documentOnly?: string;
47
+ videoOnly?: string;
48
+ audioOnly?: string;
49
+ archiveOnly?: string;
50
+ };
51
+ /**
52
+ * Configuration options for file validation
53
+ *
54
+ * @template IsRequired - Whether the field is required (affects return type)
55
+ *
56
+ * @interface FileOptions
57
+ * @property {IsRequired} [required=true] - Whether the field is required
58
+ * @property {number} [maxSize] - Maximum file size in bytes
59
+ * @property {number} [minSize] - Minimum file size in bytes
60
+ * @property {string | string[]} [type] - Allowed MIME type(s)
61
+ * @property {string[]} [typeBlacklist] - MIME types that are not allowed
62
+ * @property {string | string[]} [extension] - Allowed file extension(s)
63
+ * @property {string[]} [extensionBlacklist] - File extensions that are not allowed
64
+ * @property {RegExp | string} [namePattern] - Pattern that file name must match
65
+ * @property {RegExp | string | Array<RegExp | string>} [nameBlacklist] - Pattern(s) that file name must not match
66
+ * @property {boolean} [imageOnly=false] - If true, only allow image files
67
+ * @property {boolean} [documentOnly=false] - If true, only allow document files
68
+ * @property {boolean} [videoOnly=false] - If true, only allow video files
69
+ * @property {boolean} [audioOnly=false] - If true, only allow audio files
70
+ * @property {boolean} [archiveOnly=false] - If true, only allow archive files
71
+ * @property {boolean} [caseSensitive=false] - Whether extension matching is case-sensitive
72
+ * @property {Function} [transform] - Custom transformation function for File objects
73
+ * @property {File | null} [defaultValue] - Default value when input is empty
74
+ * @property {Record<Locale, FileMessages>} [i18n] - Custom error messages for different locales
75
+ */
76
+ type FileOptions<IsRequired extends boolean = true> = {
77
+ maxSize?: number;
78
+ minSize?: number;
79
+ type?: string | string[];
80
+ typeBlacklist?: string[];
81
+ extension?: string | string[];
82
+ extensionBlacklist?: string[];
83
+ namePattern?: RegExp | string;
84
+ nameBlacklist?: RegExp | string | Array<RegExp | string>;
85
+ imageOnly?: boolean;
86
+ documentOnly?: boolean;
87
+ videoOnly?: boolean;
88
+ audioOnly?: boolean;
89
+ archiveOnly?: boolean;
90
+ caseSensitive?: boolean;
91
+ transform?: (value: File) => File;
92
+ defaultValue?: IsRequired extends true ? File : File | null;
93
+ i18n?: Partial<Record<Locale, Partial<FileMessages>>>;
94
+ };
95
+ /**
96
+ * Type alias for file validation schema based on required flag
97
+ *
98
+ * @template IsRequired - Whether the field is required
99
+ * @description Returns ZodType with proper input/output types based on required flag
100
+ */
101
+ type FileSchema<IsRequired extends boolean> = IsRequired extends true ? ZodType<File, File | null> : ZodType<File | null, File | null>;
102
+ /**
103
+ * Creates a Zod schema for file validation with comprehensive filtering options
104
+ *
105
+ * @template IsRequired - Whether the field is required (affects return type)
106
+ * @param {IsRequired} [required=false] - Whether the field is required
107
+ * @param {Omit<FileOptions<IsRequired>, 'required'>} [options] - Configuration options for validation
108
+ * @returns {FileSchema<IsRequired>} Zod schema for file validation
109
+ *
110
+ * @description
111
+ * Creates a comprehensive file validator with MIME type filtering, size validation,
112
+ * extension validation, and extensive customization options.
113
+ *
114
+ * Features:
115
+ * - File size validation (min/max)
116
+ * - MIME type whitelist/blacklist support
117
+ * - File extension whitelist/blacklist support
118
+ * - File name pattern validation
119
+ * - Predefined file category filters (image, document, video, audio, archive)
120
+ * - Case-sensitive/insensitive extension matching
121
+ * - Custom transformation functions
122
+ * - Comprehensive internationalization
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // Basic file validation
127
+ * const basicSchema = file() // optional by default
128
+ * basicSchema.parse(new File(["content"], "test.txt"))
129
+ * basicSchema.parse(null) // ✓ Valid (optional)
130
+ *
131
+ * // Required validation
132
+ * const requiredSchema = parse(new File(["content"], "test.txt"))
133
+ (true)
134
+ * requiredSchema.parse(null) // ✗ Invalid (required)
135
+ *
136
+ *
137
+ * // Size restrictions
138
+ * const sizeSchema = file(false, {
139
+ * maxSize: 1024 * 1024, // 1MB
140
+ * minSize: 1024 // 1KB
141
+ * })
142
+ *
143
+ * // Extension restrictions
144
+ * const imageSchema = file(false, {
145
+ * extension: [".jpg", ".png", ".gif"],
146
+ * maxSize: 5 * 1024 * 1024 // 5MB
147
+ * })
148
+ *
149
+ * // MIME type restrictions
150
+ * const documentSchema = file(false, {
151
+ * type: ["application/pdf", "application/msword"],
152
+ * maxSize: 10 * 1024 * 1024 // 10MB
153
+ * })
154
+ *
155
+ * // Image files only
156
+ * const imageOnlySchema = file(false, { imageOnly: true })
157
+ *
158
+ * // Document files only
159
+ * const docOnlySchema = file(false, { documentOnly: true })
160
+ *
161
+ * // Name pattern validation
162
+ * const patternSchema = file(false, {
163
+ * namePattern: /^[a-zA-Z0-9_-]+\.(pdf|doc|docx)$/,
164
+ * maxSize: 5 * 1024 * 1024
165
+ * })
166
+ *
167
+ * // Optional with default
168
+ * const optionalSchema = file(false, {
169
+ * defaultValue: null
170
+ * })
171
+ * ```
172
+ *
173
+ * @throws {z.ZodError} When validation fails with specific error messages
174
+ * @see {@link FileOptions} for all available configuration options
175
+ */
176
+ declare function file<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<FileOptions<IsRequired>, "required">): FileSchema<IsRequired>;
177
+
178
+ export { type FileMessages, type FileOptions, type FileSchema, file };
@@ -0,0 +1,178 @@
1
+ import { ZodType } from 'zod';
2
+ import { L as Locale } from '../config-CABSSvAp.js';
3
+
4
+ /**
5
+ * @fileoverview File validator for Zod Kit
6
+ *
7
+ * Provides comprehensive file validation with MIME type filtering, size validation,
8
+ * extension validation, and extensive customization options.
9
+ *
10
+ * @author Ong Hoe Yuan
11
+ * @version 0.0.5
12
+ */
13
+
14
+ /**
15
+ * Type definition for file validation error messages
16
+ *
17
+ * @interface FileMessages
18
+ * @property {string} [required] - Message when field is required but empty
19
+ * @property {string} [invalid] - Message when file format is invalid
20
+ * @property {string} [size] - Message when file size exceeds limit
21
+ * @property {string} [minSize] - Message when file size is too small
22
+ * @property {string} [maxSize] - Message when file size exceeds maximum
23
+ * @property {string} [type] - Message when file type is not allowed
24
+ * @property {string} [extension] - Message when file extension is not allowed
25
+ * @property {string} [extensionBlacklist] - Message when file extension is blacklisted
26
+ * @property {string} [name] - Message when file name doesn't match pattern
27
+ * @property {string} [nameBlacklist] - Message when file name matches blacklisted pattern
28
+ * @property {string} [imageOnly] - Message when only image files are allowed
29
+ * @property {string} [documentOnly] - Message when only document files are allowed
30
+ * @property {string} [videoOnly] - Message when only video files are allowed
31
+ * @property {string} [audioOnly] - Message when only audio files are allowed
32
+ * @property {string} [archiveOnly] - Message when only archive files are allowed
33
+ */
34
+ type FileMessages = {
35
+ required?: string;
36
+ invalid?: string;
37
+ size?: string;
38
+ minSize?: string;
39
+ maxSize?: string;
40
+ type?: string;
41
+ extension?: string;
42
+ extensionBlacklist?: string;
43
+ name?: string;
44
+ nameBlacklist?: string;
45
+ imageOnly?: string;
46
+ documentOnly?: string;
47
+ videoOnly?: string;
48
+ audioOnly?: string;
49
+ archiveOnly?: string;
50
+ };
51
+ /**
52
+ * Configuration options for file validation
53
+ *
54
+ * @template IsRequired - Whether the field is required (affects return type)
55
+ *
56
+ * @interface FileOptions
57
+ * @property {IsRequired} [required=true] - Whether the field is required
58
+ * @property {number} [maxSize] - Maximum file size in bytes
59
+ * @property {number} [minSize] - Minimum file size in bytes
60
+ * @property {string | string[]} [type] - Allowed MIME type(s)
61
+ * @property {string[]} [typeBlacklist] - MIME types that are not allowed
62
+ * @property {string | string[]} [extension] - Allowed file extension(s)
63
+ * @property {string[]} [extensionBlacklist] - File extensions that are not allowed
64
+ * @property {RegExp | string} [namePattern] - Pattern that file name must match
65
+ * @property {RegExp | string | Array<RegExp | string>} [nameBlacklist] - Pattern(s) that file name must not match
66
+ * @property {boolean} [imageOnly=false] - If true, only allow image files
67
+ * @property {boolean} [documentOnly=false] - If true, only allow document files
68
+ * @property {boolean} [videoOnly=false] - If true, only allow video files
69
+ * @property {boolean} [audioOnly=false] - If true, only allow audio files
70
+ * @property {boolean} [archiveOnly=false] - If true, only allow archive files
71
+ * @property {boolean} [caseSensitive=false] - Whether extension matching is case-sensitive
72
+ * @property {Function} [transform] - Custom transformation function for File objects
73
+ * @property {File | null} [defaultValue] - Default value when input is empty
74
+ * @property {Record<Locale, FileMessages>} [i18n] - Custom error messages for different locales
75
+ */
76
+ type FileOptions<IsRequired extends boolean = true> = {
77
+ maxSize?: number;
78
+ minSize?: number;
79
+ type?: string | string[];
80
+ typeBlacklist?: string[];
81
+ extension?: string | string[];
82
+ extensionBlacklist?: string[];
83
+ namePattern?: RegExp | string;
84
+ nameBlacklist?: RegExp | string | Array<RegExp | string>;
85
+ imageOnly?: boolean;
86
+ documentOnly?: boolean;
87
+ videoOnly?: boolean;
88
+ audioOnly?: boolean;
89
+ archiveOnly?: boolean;
90
+ caseSensitive?: boolean;
91
+ transform?: (value: File) => File;
92
+ defaultValue?: IsRequired extends true ? File : File | null;
93
+ i18n?: Partial<Record<Locale, Partial<FileMessages>>>;
94
+ };
95
+ /**
96
+ * Type alias for file validation schema based on required flag
97
+ *
98
+ * @template IsRequired - Whether the field is required
99
+ * @description Returns ZodType with proper input/output types based on required flag
100
+ */
101
+ type FileSchema<IsRequired extends boolean> = IsRequired extends true ? ZodType<File, File | null> : ZodType<File | null, File | null>;
102
+ /**
103
+ * Creates a Zod schema for file validation with comprehensive filtering options
104
+ *
105
+ * @template IsRequired - Whether the field is required (affects return type)
106
+ * @param {IsRequired} [required=false] - Whether the field is required
107
+ * @param {Omit<FileOptions<IsRequired>, 'required'>} [options] - Configuration options for validation
108
+ * @returns {FileSchema<IsRequired>} Zod schema for file validation
109
+ *
110
+ * @description
111
+ * Creates a comprehensive file validator with MIME type filtering, size validation,
112
+ * extension validation, and extensive customization options.
113
+ *
114
+ * Features:
115
+ * - File size validation (min/max)
116
+ * - MIME type whitelist/blacklist support
117
+ * - File extension whitelist/blacklist support
118
+ * - File name pattern validation
119
+ * - Predefined file category filters (image, document, video, audio, archive)
120
+ * - Case-sensitive/insensitive extension matching
121
+ * - Custom transformation functions
122
+ * - Comprehensive internationalization
123
+ *
124
+ * @example
125
+ * ```typescript
126
+ * // Basic file validation
127
+ * const basicSchema = file() // optional by default
128
+ * basicSchema.parse(new File(["content"], "test.txt"))
129
+ * basicSchema.parse(null) // ✓ Valid (optional)
130
+ *
131
+ * // Required validation
132
+ * const requiredSchema = parse(new File(["content"], "test.txt"))
133
+ (true)
134
+ * requiredSchema.parse(null) // ✗ Invalid (required)
135
+ *
136
+ *
137
+ * // Size restrictions
138
+ * const sizeSchema = file(false, {
139
+ * maxSize: 1024 * 1024, // 1MB
140
+ * minSize: 1024 // 1KB
141
+ * })
142
+ *
143
+ * // Extension restrictions
144
+ * const imageSchema = file(false, {
145
+ * extension: [".jpg", ".png", ".gif"],
146
+ * maxSize: 5 * 1024 * 1024 // 5MB
147
+ * })
148
+ *
149
+ * // MIME type restrictions
150
+ * const documentSchema = file(false, {
151
+ * type: ["application/pdf", "application/msword"],
152
+ * maxSize: 10 * 1024 * 1024 // 10MB
153
+ * })
154
+ *
155
+ * // Image files only
156
+ * const imageOnlySchema = file(false, { imageOnly: true })
157
+ *
158
+ * // Document files only
159
+ * const docOnlySchema = file(false, { documentOnly: true })
160
+ *
161
+ * // Name pattern validation
162
+ * const patternSchema = file(false, {
163
+ * namePattern: /^[a-zA-Z0-9_-]+\.(pdf|doc|docx)$/,
164
+ * maxSize: 5 * 1024 * 1024
165
+ * })
166
+ *
167
+ * // Optional with default
168
+ * const optionalSchema = file(false, {
169
+ * defaultValue: null
170
+ * })
171
+ * ```
172
+ *
173
+ * @throws {z.ZodError} When validation fails with specific error messages
174
+ * @see {@link FileOptions} for all available configuration options
175
+ */
176
+ declare function file<IsRequired extends boolean = false>(required?: IsRequired, options?: Omit<FileOptions<IsRequired>, "required">): FileSchema<IsRequired>;
177
+
178
+ export { type FileMessages, type FileOptions, type FileSchema, file };
@@ -0,0 +1,7 @@
1
+ import {
2
+ file
3
+ } from "../chunk-WDI4QJMQ.js";
4
+ import "../chunk-6AAP4LPF.js";
5
+ export {
6
+ file
7
+ };