@hy_ong/zod-kit 0.0.4 → 0.0.6

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 (59) hide show
  1. package/.claude/settings.local.json +28 -0
  2. package/LICENSE +21 -0
  3. package/README.md +465 -97
  4. package/debug.js +21 -0
  5. package/debug.ts +16 -0
  6. package/dist/index.cjs +3127 -146
  7. package/dist/index.d.cts +3021 -25
  8. package/dist/index.d.ts +3021 -25
  9. package/dist/index.js +3081 -144
  10. package/eslint.config.mts +8 -0
  11. package/package.json +10 -9
  12. package/src/config.ts +1 -1
  13. package/src/i18n/locales/en.json +161 -25
  14. package/src/i18n/locales/zh-TW.json +165 -26
  15. package/src/index.ts +17 -7
  16. package/src/validators/common/boolean.ts +191 -0
  17. package/src/validators/common/date.ts +299 -0
  18. package/src/validators/common/datetime.ts +673 -0
  19. package/src/validators/common/email.ts +313 -0
  20. package/src/validators/common/file.ts +384 -0
  21. package/src/validators/common/id.ts +471 -0
  22. package/src/validators/common/number.ts +319 -0
  23. package/src/validators/common/password.ts +386 -0
  24. package/src/validators/common/text.ts +271 -0
  25. package/src/validators/common/time.ts +600 -0
  26. package/src/validators/common/url.ts +347 -0
  27. package/src/validators/taiwan/business-id.ts +262 -0
  28. package/src/validators/taiwan/fax.ts +327 -0
  29. package/src/validators/taiwan/mobile.ts +242 -0
  30. package/src/validators/taiwan/national-id.ts +425 -0
  31. package/src/validators/taiwan/postal-code.ts +1049 -0
  32. package/src/validators/taiwan/tel.ts +330 -0
  33. package/tests/common/boolean.test.ts +340 -92
  34. package/tests/common/date.test.ts +458 -0
  35. package/tests/common/datetime.test.ts +693 -0
  36. package/tests/common/email.test.ts +232 -60
  37. package/tests/common/file.test.ts +479 -0
  38. package/tests/common/id.test.ts +535 -0
  39. package/tests/common/number.test.ts +230 -60
  40. package/tests/common/password.test.ts +271 -44
  41. package/tests/common/text.test.ts +210 -13
  42. package/tests/common/time.test.ts +528 -0
  43. package/tests/common/url.test.ts +492 -67
  44. package/tests/taiwan/business-id.test.ts +240 -0
  45. package/tests/taiwan/fax.test.ts +463 -0
  46. package/tests/taiwan/mobile.test.ts +373 -0
  47. package/tests/taiwan/national-id.test.ts +435 -0
  48. package/tests/taiwan/postal-code.test.ts +705 -0
  49. package/tests/taiwan/tel.test.ts +467 -0
  50. package/eslint.config.mjs +0 -10
  51. package/src/common/boolean.ts +0 -36
  52. package/src/common/date.ts +0 -43
  53. package/src/common/email.ts +0 -44
  54. package/src/common/integer.ts +0 -46
  55. package/src/common/number.ts +0 -37
  56. package/src/common/password.ts +0 -33
  57. package/src/common/text.ts +0 -34
  58. package/src/common/url.ts +0 -37
  59. package/tests/common/integer.test.ts +0 -90
package/dist/index.d.ts CHANGED
@@ -1,54 +1,1375 @@
1
- import { ZodBoolean, ZodNullable, ZodString, ZodNumber } from 'zod';
1
+ import { ZodBoolean, ZodNullable, ZodString, ZodType, ZodNumber } from 'zod';
2
+ import dayjs from 'dayjs';
2
3
 
4
+ type Locale = "zh-TW" | "en";
5
+ declare const setLocale: (locale: Locale) => void;
6
+ declare const getLocale: () => Locale;
7
+
8
+ /**
9
+ * @fileoverview Boolean validator for Zod Kit
10
+ *
11
+ * Provides flexible boolean validation with support for various truthy/falsy values,
12
+ * strict mode validation, and comprehensive transformation options.
13
+ *
14
+ * @author Ong Hoe Yuan
15
+ * @version 0.0.5
16
+ */
17
+
18
+ /**
19
+ * Type definition for boolean validation error messages
20
+ *
21
+ * @interface BooleanMessages
22
+ * @property {string} [required] - Message when field is required but empty
23
+ * @property {string} [shouldBeTrue] - Message when value should be true but isn't
24
+ * @property {string} [shouldBeFalse] - Message when value should be false but isn't
25
+ * @property {string} [invalid] - Message when value is not a valid boolean
26
+ */
27
+ type BooleanMessages = {
28
+ required?: string;
29
+ shouldBeTrue?: string;
30
+ shouldBeFalse?: string;
31
+ invalid?: string;
32
+ };
33
+ /**
34
+ * Configuration options for boolean validation
35
+ *
36
+ * @template IsRequired - Whether the field is required (affects return type)
37
+ *
38
+ * @interface BooleanOptions
39
+ * @property {IsRequired} [required=true] - Whether the field is required
40
+ * @property {boolean | null} [defaultValue] - Default value when input is empty
41
+ * @property {boolean} [shouldBe] - Specific boolean value that must be matched
42
+ * @property {unknown[]} [truthyValues] - Array of values that should be treated as true
43
+ * @property {unknown[]} [falsyValues] - Array of values that should be treated as false
44
+ * @property {boolean} [strict=false] - If true, only accepts actual boolean values
45
+ * @property {Function} [transform] - Custom transformation function for boolean values
46
+ * @property {Record<Locale, BooleanMessages>} [i18n] - Custom error messages for different locales
47
+ */
3
48
  type BooleanOptions<IsRequired extends boolean = true> = {
4
49
  required?: IsRequired;
5
50
  defaultValue?: IsRequired extends true ? boolean : boolean | null;
6
51
  shouldBe?: boolean;
52
+ truthyValues?: unknown[];
53
+ falsyValues?: unknown[];
54
+ strict?: boolean;
55
+ transform?: (value: boolean) => boolean;
56
+ i18n?: Record<Locale, BooleanMessages>;
7
57
  };
58
+ /**
59
+ * Type alias for boolean validation schema based on required flag
60
+ *
61
+ * @template IsRequired - Whether the field is required
62
+ * @typedef BooleanSchema
63
+ * @description Returns ZodBoolean if required, ZodNullable<ZodBoolean> if optional
64
+ */
8
65
  type BooleanSchema<IsRequired extends boolean> = IsRequired extends true ? ZodBoolean : ZodNullable<ZodBoolean>;
66
+ /**
67
+ * Creates a Zod schema for boolean validation with flexible value interpretation
68
+ *
69
+ * @template IsRequired - Whether the field is required (affects return type)
70
+ * @param {BooleanOptions<IsRequired>} [options] - Configuration options for boolean validation
71
+ * @returns {BooleanSchema<IsRequired>} Zod schema for boolean validation
72
+ *
73
+ * @description
74
+ * Creates a flexible boolean validator that can interpret various values as true/false,
75
+ * supports strict mode for type safety, and provides comprehensive transformation options.
76
+ *
77
+ * Features:
78
+ * - Flexible truthy/falsy value interpretation
79
+ * - Strict mode for type safety
80
+ * - Custom transformation functions
81
+ * - Specific boolean value requirements
82
+ * - Comprehensive internationalization
83
+ * - Default value support
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * // Basic boolean validation
88
+ * const basicSchema = boolean()
89
+ * basicSchema.parse(true) // ✓ Valid
90
+ * basicSchema.parse("true") // ✓ Valid (converted to true)
91
+ *
92
+ * // Strict mode (only actual booleans)
93
+ * const strictSchema = boolean({ strict: true })
94
+ * strictSchema.parse(true) // ✓ Valid
95
+ * strictSchema.parse("true") // ✗ Invalid
96
+ *
97
+ * // Must be true
98
+ * const mustBeTrueSchema = boolean({ shouldBe: true })
99
+ * mustBeTrueSchema.parse(true) // ✓ Valid
100
+ * mustBeTrueSchema.parse(false) // ✗ Invalid
101
+ *
102
+ * // Custom truthy/falsy values
103
+ * const customSchema = boolean({
104
+ * truthyValues: ["yes", "on", 1],
105
+ * falsyValues: ["no", "off", 0]
106
+ * })
107
+ * customSchema.parse("yes") // ✓ Valid (converted to true)
108
+ *
109
+ * // Optional with default
110
+ * const optionalSchema = boolean({
111
+ * required: false,
112
+ * defaultValue: false
113
+ * })
114
+ * ```
115
+ *
116
+ * @throws {z.ZodError} When validation fails with specific error messages
117
+ * @see {@link BooleanOptions} for all available configuration options
118
+ */
9
119
  declare function boolean<IsRequired extends boolean = true>(options?: BooleanOptions<IsRequired>): BooleanSchema<IsRequired>;
10
120
 
11
- type EmailOptions<IsRequired extends boolean = true> = {
121
+ /**
122
+ * @fileoverview Date validator for Zod Kit
123
+ *
124
+ * Provides comprehensive date validation with format support, range validation,
125
+ * temporal constraints, and weekday/weekend filtering using dayjs library.
126
+ *
127
+ * @author Ong Hoe Yuan
128
+ * @version 0.0.5
129
+ */
130
+
131
+ /**
132
+ * Type definition for date validation error messages
133
+ *
134
+ * @interface DateMessages
135
+ * @property {string} [required] - Message when field is required but empty
136
+ * @property {string} [invalid] - Message when date is invalid
137
+ * @property {string} [format] - Message when date doesn't match expected format
138
+ * @property {string} [min] - Message when date is before minimum allowed
139
+ * @property {string} [max] - Message when date is after maximum allowed
140
+ * @property {string} [includes] - Message when date string doesn't contain required text
141
+ * @property {string} [excludes] - Message when date string contains forbidden text
142
+ * @property {string} [past] - Message when date must be in the past
143
+ * @property {string} [future] - Message when date must be in the future
144
+ * @property {string} [today] - Message when date must be today
145
+ * @property {string} [notToday] - Message when date must not be today
146
+ * @property {string} [weekday] - Message when date must be a weekday
147
+ * @property {string} [notWeekday] - Message when date must not be a weekday
148
+ * @property {string} [weekend] - Message when date must be a weekend
149
+ * @property {string} [notWeekend] - Message when date must not be a weekend
150
+ */
151
+ type DateMessages = {
152
+ required?: string;
153
+ invalid?: string;
154
+ format?: string;
155
+ min?: string;
156
+ max?: string;
157
+ includes?: string;
158
+ excludes?: string;
159
+ past?: string;
160
+ future?: string;
161
+ today?: string;
162
+ notToday?: string;
163
+ weekday?: string;
164
+ notWeekday?: string;
165
+ weekend?: string;
166
+ notWeekend?: string;
167
+ };
168
+ /**
169
+ * Configuration options for date validation
170
+ *
171
+ * @template IsRequired - Whether the field is required (affects return type)
172
+ *
173
+ * @interface DateOptions
174
+ * @property {IsRequired} [required=true] - Whether the field is required
175
+ * @property {string} [min] - Minimum allowed date (in same format as specified)
176
+ * @property {string} [max] - Maximum allowed date (in same format as specified)
177
+ * @property {string} [format="YYYY-MM-DD"] - Date format for parsing and validation
178
+ * @property {string} [includes] - String that must be included in the date
179
+ * @property {string | string[]} [excludes] - String(s) that must not be included
180
+ * @property {boolean} [mustBePast] - Whether date must be in the past
181
+ * @property {boolean} [mustBeFuture] - Whether date must be in the future
182
+ * @property {boolean} [mustBeToday] - Whether date must be today
183
+ * @property {boolean} [mustNotBeToday] - Whether date must not be today
184
+ * @property {boolean} [weekdaysOnly] - Whether date must be a weekday (Monday-Friday)
185
+ * @property {boolean} [weekendsOnly] - Whether date must be a weekend (Saturday-Sunday)
186
+ * @property {Function} [transform] - Custom transformation function for date strings
187
+ * @property {string | null} [defaultValue] - Default value when input is empty
188
+ * @property {Record<Locale, DateMessages>} [i18n] - Custom error messages for different locales
189
+ */
190
+ type DateOptions<IsRequired extends boolean = true> = {
191
+ required?: IsRequired;
192
+ min?: string;
193
+ max?: string;
194
+ format?: string;
195
+ includes?: string;
196
+ excludes?: string | string[];
197
+ mustBePast?: boolean;
198
+ mustBeFuture?: boolean;
199
+ mustBeToday?: boolean;
200
+ mustNotBeToday?: boolean;
201
+ weekdaysOnly?: boolean;
202
+ weekendsOnly?: boolean;
203
+ transform?: (value: string) => string;
204
+ defaultValue?: IsRequired extends true ? string : string | null;
205
+ i18n?: Record<Locale, DateMessages>;
206
+ };
207
+ /**
208
+ * Type alias for date validation schema based on required flag
209
+ *
210
+ * @template IsRequired - Whether the field is required
211
+ * @typedef DateSchema
212
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
213
+ */
214
+ type DateSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
215
+ /**
216
+ * Creates a Zod schema for date validation with temporal constraints
217
+ *
218
+ * @template IsRequired - Whether the field is required (affects return type)
219
+ * @param {DateOptions<IsRequired>} [options] - Configuration options for date validation
220
+ * @returns {DateSchema<IsRequired>} Zod schema for date validation
221
+ *
222
+ * @description
223
+ * Creates a comprehensive date validator with format support, range validation,
224
+ * temporal constraints, and weekday/weekend filtering using dayjs library.
225
+ *
226
+ * Features:
227
+ * - Flexible date format parsing (default: YYYY-MM-DD)
228
+ * - Range validation (min/max dates)
229
+ * - Temporal validation (past/future/today)
230
+ * - Weekday/weekend filtering
231
+ * - Content inclusion/exclusion
232
+ * - Custom transformation functions
233
+ * - Comprehensive internationalization
234
+ * - Strict date parsing with format validation
235
+ *
236
+ * @example
237
+ * ```typescript
238
+ * // Basic date validation (YYYY-MM-DD)
239
+ * const basicSchema = date()
240
+ * basicSchema.parse("2024-03-15") // ✓ Valid
241
+ * basicSchema.parse("2024-13-01") // ✗ Invalid (month 13)
242
+ *
243
+ * // Custom format
244
+ * const customFormatSchema = date({ format: "DD/MM/YYYY" })
245
+ * customFormatSchema.parse("15/03/2024") // ✓ Valid
246
+ * customFormatSchema.parse("2024-03-15") // ✗ Invalid (wrong format)
247
+ *
248
+ * // Date range validation
249
+ * const rangeSchema = date({
250
+ * min: "2024-01-01",
251
+ * max: "2024-12-31"
252
+ * })
253
+ * rangeSchema.parse("2024-06-15") // ✓ Valid
254
+ * rangeSchema.parse("2023-12-31") // ✗ Invalid (before min)
255
+ *
256
+ * // Future dates only
257
+ * const futureSchema = date({ mustBeFuture: true })
258
+ * futureSchema.parse("2030-01-01") // ✓ Valid (assuming current date < 2030)
259
+ * futureSchema.parse("2020-01-01") // ✗ Invalid (past date)
260
+ *
261
+ * // Weekdays only (Monday-Friday)
262
+ * const weekdaySchema = date({ weekdaysOnly: true })
263
+ * weekdaySchema.parse("2024-03-15") // ✓ Valid (if Friday)
264
+ * weekdaySchema.parse("2024-03-16") // ✗ Invalid (if Saturday)
265
+ *
266
+ * // Business date validation
267
+ * const businessSchema = date({
268
+ * format: "YYYY-MM-DD",
269
+ * mustBeFuture: true,
270
+ * weekdaysOnly: true
271
+ * })
272
+ *
273
+ * // Optional with default
274
+ * const optionalSchema = date({
275
+ * required: false,
276
+ * defaultValue: "2024-01-01"
277
+ * })
278
+ * ```
279
+ *
280
+ * @throws {z.ZodError} When validation fails with specific error messages
281
+ * @see {@link DateOptions} for all available configuration options
282
+ */
283
+ declare function date<IsRequired extends boolean = true>(options?: DateOptions<IsRequired>): DateSchema<IsRequired>;
284
+
285
+ /**
286
+ * @fileoverview DateTime validator for Zod Kit
287
+ *
288
+ * Provides comprehensive datetime validation with support for multiple formats,
289
+ * timezone handling, range validation, and internationalization.
290
+ *
291
+ * @author Ong Hoe Yuan
292
+ * @version 0.0.5
293
+ */
294
+
295
+ /**
296
+ * Type definition for datetime validation error messages
297
+ *
298
+ * @interface DateTimeMessages
299
+ * @property {string} [required] - Message when field is required but empty
300
+ * @property {string} [invalid] - Message when datetime format is invalid
301
+ * @property {string} [format] - Message when datetime doesn't match expected format
302
+ * @property {string} [min] - Message when datetime is before minimum allowed
303
+ * @property {string} [max] - Message when datetime is after maximum allowed
304
+ * @property {string} [includes] - Message when datetime doesn't include required string
305
+ * @property {string} [excludes] - Message when datetime contains excluded string
306
+ * @property {string} [past] - Message when datetime must be in the past
307
+ * @property {string} [future] - Message when datetime must be in the future
308
+ * @property {string} [today] - Message when datetime must be today
309
+ * @property {string} [notToday] - Message when datetime must not be today
310
+ * @property {string} [weekday] - Message when datetime must be a weekday
311
+ * @property {string} [weekend] - Message when datetime must be a weekend
312
+ * @property {string} [hour] - Message when hour is outside allowed range
313
+ * @property {string} [minute] - Message when minute doesn't match step requirement
314
+ * @property {string} [customRegex] - Message when custom regex validation fails
315
+ * @property {string} [notInWhitelist] - Message when value is not in whitelist
316
+ */
317
+ type DateTimeMessages = {
318
+ required?: string;
319
+ invalid?: string;
320
+ format?: string;
321
+ min?: string;
322
+ max?: string;
323
+ includes?: string;
324
+ excludes?: string;
325
+ past?: string;
326
+ future?: string;
327
+ today?: string;
328
+ notToday?: string;
329
+ weekday?: string;
330
+ weekend?: string;
331
+ hour?: string;
332
+ minute?: string;
333
+ customRegex?: string;
334
+ notInWhitelist?: string;
335
+ };
336
+ /**
337
+ * Supported datetime formats for validation
338
+ *
339
+ * @typedef {string} DateTimeFormat
340
+ *
341
+ * Standard formats:
342
+ * - YYYY-MM-DD HH:mm: ISO-style date with 24-hour time (2024-03-15 14:30)
343
+ * - YYYY-MM-DD HH:mm:ss: ISO-style date with seconds (2024-03-15 14:30:45)
344
+ * - YYYY-MM-DD hh:mm A: ISO-style date with 12-hour time (2024-03-15 02:30 PM)
345
+ * - YYYY-MM-DD hh:mm:ss A: ISO-style date with 12-hour time and seconds (2024-03-15 02:30:45 PM)
346
+ *
347
+ * Regional formats:
348
+ * - DD/MM/YYYY HH:mm: European format (15/03/2024 14:30)
349
+ * - DD/MM/YYYY HH:mm:ss: European format with seconds (15/03/2024 14:30:45)
350
+ * - DD/MM/YYYY hh:mm A: European format with 12-hour time (15/03/2024 02:30 PM)
351
+ * - MM/DD/YYYY HH:mm: US format (03/15/2024 14:30)
352
+ * - MM/DD/YYYY hh:mm A: US format with 12-hour time (03/15/2024 02:30 PM)
353
+ * - YYYY/MM/DD HH:mm: Alternative slash format (2024/03/15 14:30)
354
+ * - DD-MM-YYYY HH:mm: European dash format (15-03-2024 14:30)
355
+ * - MM-DD-YYYY HH:mm: US dash format (03-15-2024 14:30)
356
+ *
357
+ * Special formats:
358
+ * - ISO: ISO 8601 format (2024-03-15T14:30:45.000Z)
359
+ * - RFC: RFC 2822 format (Fri, 15 Mar 2024 14:30:45 GMT)
360
+ * - UNIX: Unix timestamp (1710508245)
361
+ */
362
+ type DateTimeFormat = "YYYY-MM-DD HH:mm" | "YYYY-MM-DD HH:mm:ss" | "YYYY-MM-DD hh:mm A" | "YYYY-MM-DD hh:mm:ss A" | "DD/MM/YYYY HH:mm" | "DD/MM/YYYY HH:mm:ss" | "DD/MM/YYYY hh:mm A" | "MM/DD/YYYY HH:mm" | "MM/DD/YYYY hh:mm A" | "YYYY/MM/DD HH:mm" | "DD-MM-YYYY HH:mm" | "MM-DD-YYYY HH:mm" | "ISO" | "RFC" | "UNIX";
363
+ /**
364
+ * Configuration options for datetime validation
365
+ *
366
+ * @template IsRequired - Whether the field is required (affects return type)
367
+ *
368
+ * @interface DateTimeOptions
369
+ * @property {IsRequired} [required=true] - Whether the field is required
370
+ * @property {DateTimeFormat} [format="YYYY-MM-DD HH:mm"] - Expected datetime format
371
+ * @property {string | Date} [min] - Minimum allowed datetime
372
+ * @property {string | Date} [max] - Maximum allowed datetime
373
+ * @property {number} [minHour] - Minimum allowed hour (0-23)
374
+ * @property {number} [maxHour] - Maximum allowed hour (0-23)
375
+ * @property {number[]} [allowedHours] - Specific hours that are allowed
376
+ * @property {number} [minuteStep] - Required minute intervals (e.g., 15 for :00, :15, :30, :45)
377
+ * @property {string} [timezone] - Timezone for parsing and validation (e.g., "Asia/Taipei")
378
+ * @property {string} [includes] - String that must be included in the datetime
379
+ * @property {string | string[]} [excludes] - String(s) that must not be included
380
+ * @property {RegExp} [regex] - Custom regex for validation (overrides format validation)
381
+ * @property {"trim" | "trimStart" | "trimEnd" | "none"} [trimMode="trim"] - Whitespace handling
382
+ * @property {"upper" | "lower" | "none"} [casing="none"] - Case transformation
383
+ * @property {boolean} [mustBePast] - Whether datetime must be in the past
384
+ * @property {boolean} [mustBeFuture] - Whether datetime must be in the future
385
+ * @property {boolean} [mustBeToday] - Whether datetime must be today
386
+ * @property {boolean} [mustNotBeToday] - Whether datetime must not be today
387
+ * @property {boolean} [weekdaysOnly] - Whether datetime must be a weekday (Monday-Friday)
388
+ * @property {boolean} [weekendsOnly] - Whether datetime must be a weekend (Saturday-Sunday)
389
+ * @property {string[]} [whitelist] - Specific datetime strings that are always allowed
390
+ * @property {boolean} [whitelistOnly=false] - If true, only values in whitelist are allowed
391
+ * @property {Function} [transform] - Custom transformation function applied before validation
392
+ * @property {string | null} [defaultValue] - Default value when input is empty
393
+ * @property {Record<Locale, DateTimeMessages>} [i18n] - Custom error messages for different locales
394
+ */
395
+ type DateTimeOptions<IsRequired extends boolean = true> = {
12
396
  required?: IsRequired;
397
+ format?: DateTimeFormat;
398
+ min?: string | Date;
399
+ max?: string | Date;
400
+ minHour?: number;
401
+ maxHour?: number;
402
+ allowedHours?: number[];
403
+ minuteStep?: number;
404
+ timezone?: string;
405
+ includes?: string;
406
+ excludes?: string | string[];
407
+ regex?: RegExp;
408
+ trimMode?: "trim" | "trimStart" | "trimEnd" | "none";
409
+ casing?: "upper" | "lower" | "none";
410
+ mustBePast?: boolean;
411
+ mustBeFuture?: boolean;
412
+ mustBeToday?: boolean;
413
+ mustNotBeToday?: boolean;
414
+ weekdaysOnly?: boolean;
415
+ weekendsOnly?: boolean;
416
+ whitelist?: string[];
417
+ whitelistOnly?: boolean;
418
+ transform?: (value: string) => string;
419
+ defaultValue?: IsRequired extends true ? string : string | null;
420
+ i18n?: Record<Locale, DateTimeMessages>;
421
+ };
422
+ /**
423
+ * Type alias for datetime validation schema based on required flag
424
+ *
425
+ * @template IsRequired - Whether the field is required
426
+ * @typedef DateTimeSchema
427
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
428
+ */
429
+ type DateTimeSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
430
+ /**
431
+ * Regular expression patterns for datetime format validation
432
+ *
433
+ * @constant {Record<DateTimeFormat, RegExp>} DATETIME_PATTERNS
434
+ * @description Maps each supported datetime format to its corresponding regex pattern
435
+ *
436
+ * Pattern explanations:
437
+ * - YYYY-MM-DD HH:mm: 4-digit year, 2-digit month, 2-digit day, 24-hour time
438
+ * - ISO: ISO 8601 format with optional milliseconds and timezone
439
+ * - RFC: RFC 2822 format with day name, date, time, and timezone
440
+ * - UNIX: 10-digit Unix timestamp
441
+ */
442
+ declare const DATETIME_PATTERNS: Record<DateTimeFormat, RegExp>;
443
+ /**
444
+ * Validates if a datetime string matches the specified format pattern
445
+ *
446
+ * @param {string} value - The datetime string to validate
447
+ * @param {DateTimeFormat} format - The expected datetime format
448
+ * @returns {boolean} True if the datetime is valid for the given format
449
+ *
450
+ * @description
451
+ * Performs both regex pattern matching and actual datetime parsing validation.
452
+ * Returns false if either the pattern doesn't match or the parsed datetime is invalid.
453
+ *
454
+ * @example
455
+ * ```typescript
456
+ * validateDateTimeFormat("2024-03-15 14:30", "YYYY-MM-DD HH:mm") // true
457
+ * validateDateTimeFormat("2024-03-15 25:30", "YYYY-MM-DD HH:mm") // false (invalid hour)
458
+ * validateDateTimeFormat("15/03/2024", "YYYY-MM-DD HH:mm") // false (wrong format)
459
+ * ```
460
+ */
461
+ declare const validateDateTimeFormat: (value: string, format: DateTimeFormat) => boolean;
462
+ /**
463
+ * Parses a datetime string into a dayjs object using the specified format
464
+ *
465
+ * @param {string} value - The datetime string to parse
466
+ * @param {DateTimeFormat} format - The expected datetime format
467
+ * @param {string} [timezone] - Optional timezone for parsing (e.g., "Asia/Taipei")
468
+ * @returns {dayjs.Dayjs | null} Parsed dayjs object or null if parsing fails
469
+ *
470
+ * @description
471
+ * Handles different datetime formats including ISO, RFC, Unix timestamps, and custom formats.
472
+ * Uses strict parsing mode for custom formats to ensure accuracy.
473
+ * Applies timezone conversion if specified.
474
+ *
475
+ * @example
476
+ * ```typescript
477
+ * parseDateTimeValue("2024-03-15 14:30", "YYYY-MM-DD HH:mm")
478
+ * // Returns dayjs object for March 15, 2024 at 2:30 PM
479
+ *
480
+ * parseDateTimeValue("1710508245", "UNIX")
481
+ * // Returns dayjs object for the Unix timestamp
482
+ *
483
+ * parseDateTimeValue("2024-03-15T14:30:45.000Z", "ISO")
484
+ * // Returns dayjs object for the ISO datetime
485
+ * ```
486
+ *
487
+ * @throws {Error} Returns null if parsing fails or datetime is invalid
488
+ */
489
+ declare const parseDateTimeValue: (value: string, format: DateTimeFormat, timezone?: string) => dayjs.Dayjs | null;
490
+ /**
491
+ * Normalizes a datetime string to the specified format
492
+ *
493
+ * @param {string} value - The datetime string to normalize
494
+ * @param {DateTimeFormat} format - The target datetime format
495
+ * @param {string} [timezone] - Optional timezone for formatting
496
+ * @returns {string | null} Normalized datetime string or null if parsing fails
497
+ *
498
+ * @description
499
+ * Parses the input datetime and formats it according to the specified format.
500
+ * Handles special formats like ISO, RFC, and Unix timestamps appropriately.
501
+ * Returns null if the input datetime cannot be parsed.
502
+ *
503
+ * @example
504
+ * ```typescript
505
+ * normalizeDateTimeValue("2024-3-15 2:30 PM", "YYYY-MM-DD HH:mm")
506
+ * // Returns "2024-03-15 14:30"
507
+ *
508
+ * normalizeDateTimeValue("1710508245", "ISO")
509
+ * // Returns "2024-03-15T14:30:45.000Z"
510
+ * ```
511
+ */
512
+ declare const normalizeDateTimeValue: (value: string, format: DateTimeFormat, timezone?: string) => string | null;
513
+ /**
514
+ * Creates a Zod schema for datetime validation with comprehensive options
515
+ *
516
+ * @template IsRequired - Whether the field is required (affects return type)
517
+ * @param {DateTimeOptions<IsRequired>} [options] - Configuration options for datetime validation
518
+ * @returns {DateTimeSchema<IsRequired>} Zod schema for datetime validation
519
+ *
520
+ * @description
521
+ * Creates a comprehensive datetime validator that supports multiple formats, timezone handling,
522
+ * range validation, temporal constraints, and extensive customization options.
523
+ *
524
+ * Features:
525
+ * - Multiple datetime formats (ISO, RFC, Unix, regional formats)
526
+ * - Timezone support and conversion
527
+ * - Range validation (min/max datetime)
528
+ * - Hour and minute constraints
529
+ * - Temporal validation (past/future/today)
530
+ * - Weekday/weekend validation
531
+ * - Whitelist/blacklist support
532
+ * - Custom regex patterns
533
+ * - String transformation and case handling
534
+ * - Comprehensive internationalization
535
+ *
536
+ * @example
537
+ * ```typescript
538
+ * // Basic datetime validation
539
+ * const basicSchema = datetime()
540
+ * basicSchema.parse("2024-03-15 14:30") // ✓ Valid
541
+ *
542
+ * // Business hours validation
543
+ * const businessHours = datetime({
544
+ * format: "YYYY-MM-DD HH:mm",
545
+ * minHour: 9,
546
+ * maxHour: 17,
547
+ * weekdaysOnly: true
548
+ * })
549
+ *
550
+ * // Timezone-aware validation
551
+ * const timezoneSchema = datetime({
552
+ * timezone: "Asia/Taipei",
553
+ * mustBeFuture: true
554
+ * })
555
+ *
556
+ * // Multiple format support
557
+ * const flexibleSchema = datetime({
558
+ * format: "DD/MM/YYYY HH:mm"
559
+ * })
560
+ * flexibleSchema.parse("15/03/2024 14:30") // ✓ Valid
561
+ *
562
+ * // Optional with default
563
+ * const optionalSchema = datetime({
564
+ * required: false,
565
+ * defaultValue: "2024-01-01 00:00"
566
+ * })
567
+ * ```
568
+ *
569
+ * @throws {z.ZodError} When validation fails with specific error messages
570
+ * @see {@link DateTimeOptions} for all available configuration options
571
+ * @see {@link DateTimeFormat} for supported datetime formats
572
+ */
573
+ declare function datetime<IsRequired extends boolean = true>(options?: DateTimeOptions<IsRequired>): DateTimeSchema<IsRequired>;
574
+
575
+ /**
576
+ * @fileoverview Email validator for Zod Kit
577
+ *
578
+ * Provides comprehensive email validation with domain filtering, business email
579
+ * validation, disposable email detection, and extensive customization options.
580
+ *
581
+ * @author Ong Hoe Yuan
582
+ * @version 0.0.5
583
+ */
584
+
585
+ /**
586
+ * Type definition for email validation error messages
587
+ *
588
+ * @interface EmailMessages
589
+ * @property {string} [required] - Message when field is required but empty
590
+ * @property {string} [invalid] - Message when email format is invalid
591
+ * @property {string} [minLength] - Message when email is too short
592
+ * @property {string} [maxLength] - Message when email is too long
593
+ * @property {string} [includes] - Message when email doesn't contain required string
594
+ * @property {string} [domain] - Message when email domain is not allowed
595
+ * @property {string} [domainBlacklist] - Message when email domain is blacklisted
596
+ * @property {string} [businessOnly] - Message when free email providers are not allowed
597
+ * @property {string} [noDisposable] - Message when disposable email addresses are not allowed
598
+ */
599
+ type EmailMessages = {
600
+ required?: string;
601
+ invalid?: string;
602
+ minLength?: string;
603
+ maxLength?: string;
604
+ includes?: string;
13
605
  domain?: string;
14
- min?: number;
15
- max?: number;
606
+ domainBlacklist?: string;
607
+ businessOnly?: string;
608
+ noDisposable?: string;
609
+ };
610
+ /**
611
+ * Configuration options for email validation
612
+ *
613
+ * @template IsRequired - Whether the field is required (affects return type)
614
+ *
615
+ * @interface EmailOptions
616
+ * @property {IsRequired} [required=true] - Whether the field is required
617
+ * @property {string | string[]} [domain] - Allowed domain(s) for email addresses
618
+ * @property {string[]} [domainBlacklist] - Domains that are not allowed
619
+ * @property {number} [minLength] - Minimum length of email address
620
+ * @property {number} [maxLength] - Maximum length of email address
621
+ * @property {string} [includes] - String that must be included in the email
622
+ * @property {string | string[]} [excludes] - String(s) that must not be included
623
+ * @property {boolean} [allowSubdomains=true] - Whether to allow subdomains in domain validation
624
+ * @property {boolean} [businessOnly=false] - If true, reject common free email providers
625
+ * @property {boolean} [noDisposable=false] - If true, reject disposable email addresses
626
+ * @property {boolean} [lowercase=true] - Whether to convert email to lowercase
627
+ * @property {Function} [transform] - Custom transformation function for email strings
628
+ * @property {string | null} [defaultValue] - Default value when input is empty
629
+ * @property {Record<Locale, EmailMessages>} [i18n] - Custom error messages for different locales
630
+ */
631
+ type EmailOptions<IsRequired extends boolean = true> = {
632
+ required?: IsRequired;
633
+ domain?: string | string[];
634
+ domainBlacklist?: string[];
635
+ minLength?: number;
636
+ maxLength?: number;
16
637
  includes?: string;
638
+ excludes?: string | string[];
639
+ allowSubdomains?: boolean;
640
+ businessOnly?: boolean;
641
+ noDisposable?: boolean;
642
+ lowercase?: boolean;
643
+ transform?: (value: string) => string;
644
+ defaultValue?: IsRequired extends true ? string : string | null;
645
+ i18n?: Record<Locale, EmailMessages>;
17
646
  };
647
+ /**
648
+ * Type alias for email validation schema based on required flag
649
+ *
650
+ * @template IsRequired - Whether the field is required
651
+ * @typedef EmailSchema
652
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
653
+ */
18
654
  type EmailSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
655
+ /**
656
+ * Creates a Zod schema for email validation with comprehensive filtering options
657
+ *
658
+ * @template IsRequired - Whether the field is required (affects return type)
659
+ * @param {EmailOptions<IsRequired>} [options] - Configuration options for email validation
660
+ * @returns {EmailSchema<IsRequired>} Zod schema for email validation
661
+ *
662
+ * @description
663
+ * Creates a comprehensive email validator with domain filtering, business email
664
+ * validation, disposable email detection, and extensive customization options.
665
+ *
666
+ * Features:
667
+ * - RFC-compliant email format validation
668
+ * - Domain whitelist/blacklist support
669
+ * - Business email validation (excludes free providers)
670
+ * - Disposable email detection
671
+ * - Subdomain support configuration
672
+ * - Length validation
673
+ * - Content inclusion/exclusion
674
+ * - Automatic lowercase conversion
675
+ * - Custom transformation functions
676
+ * - Comprehensive internationalization
677
+ *
678
+ * @example
679
+ * ```typescript
680
+ * // Basic email validation
681
+ * const basicSchema = email()
682
+ * basicSchema.parse("user@example.com") // ✓ Valid
683
+ *
684
+ * // Domain restriction
685
+ * const domainSchema = email({
686
+ * domain: ["company.com", "organization.org"]
687
+ * })
688
+ * domainSchema.parse("user@company.com") // ✓ Valid
689
+ * domainSchema.parse("user@gmail.com") // ✗ Invalid
690
+ *
691
+ * // Business emails only (no free providers)
692
+ * const businessSchema = email({ businessOnly: true })
693
+ * businessSchema.parse("user@company.com") // ✓ Valid
694
+ * businessSchema.parse("user@gmail.com") // ✗ Invalid
695
+ *
696
+ * // No disposable emails
697
+ * const noDisposableSchema = email({ noDisposable: true })
698
+ * noDisposableSchema.parse("user@company.com") // ✓ Valid
699
+ * noDisposableSchema.parse("user@10minutemail.com") // ✗ Invalid
700
+ *
701
+ * // Domain blacklist
702
+ * const blacklistSchema = email({
703
+ * domainBlacklist: ["spam.com", "blocked.org"]
704
+ * })
705
+ *
706
+ * // Optional with default
707
+ * const optionalSchema = email({
708
+ * required: false,
709
+ * defaultValue: null
710
+ * })
711
+ * ```
712
+ *
713
+ * @throws {z.ZodError} When validation fails with specific error messages
714
+ * @see {@link EmailOptions} for all available configuration options
715
+ */
19
716
  declare function email<IsRequired extends boolean = true>(options?: EmailOptions<IsRequired>): EmailSchema<IsRequired>;
20
717
 
21
- type UrlOptions<IsRequired extends boolean = true> = {
718
+ /**
719
+ * @fileoverview File validator for Zod Kit
720
+ *
721
+ * Provides comprehensive file validation with MIME type filtering, size validation,
722
+ * extension validation, and extensive customization options.
723
+ *
724
+ * @author Ong Hoe Yuan
725
+ * @version 0.0.5
726
+ */
727
+
728
+ /**
729
+ * Type definition for file validation error messages
730
+ *
731
+ * @interface FileMessages
732
+ * @property {string} [required] - Message when field is required but empty
733
+ * @property {string} [invalid] - Message when file format is invalid
734
+ * @property {string} [size] - Message when file size exceeds limit
735
+ * @property {string} [minSize] - Message when file size is too small
736
+ * @property {string} [maxSize] - Message when file size exceeds maximum
737
+ * @property {string} [type] - Message when file type is not allowed
738
+ * @property {string} [extension] - Message when file extension is not allowed
739
+ * @property {string} [extensionBlacklist] - Message when file extension is blacklisted
740
+ * @property {string} [name] - Message when file name doesn't match pattern
741
+ * @property {string} [nameBlacklist] - Message when file name matches blacklisted pattern
742
+ * @property {string} [imageOnly] - Message when only image files are allowed
743
+ * @property {string} [documentOnly] - Message when only document files are allowed
744
+ * @property {string} [videoOnly] - Message when only video files are allowed
745
+ * @property {string} [audioOnly] - Message when only audio files are allowed
746
+ * @property {string} [archiveOnly] - Message when only archive files are allowed
747
+ */
748
+ type FileMessages = {
749
+ required?: string;
750
+ invalid?: string;
751
+ size?: string;
752
+ minSize?: string;
753
+ maxSize?: string;
754
+ type?: string;
755
+ extension?: string;
756
+ extensionBlacklist?: string;
757
+ name?: string;
758
+ nameBlacklist?: string;
759
+ imageOnly?: string;
760
+ documentOnly?: string;
761
+ videoOnly?: string;
762
+ audioOnly?: string;
763
+ archiveOnly?: string;
764
+ };
765
+ /**
766
+ * Configuration options for file validation
767
+ *
768
+ * @template IsRequired - Whether the field is required (affects return type)
769
+ *
770
+ * @interface FileOptions
771
+ * @property {IsRequired} [required=true] - Whether the field is required
772
+ * @property {number} [maxSize] - Maximum file size in bytes
773
+ * @property {number} [minSize] - Minimum file size in bytes
774
+ * @property {string | string[]} [type] - Allowed MIME type(s)
775
+ * @property {string[]} [typeBlacklist] - MIME types that are not allowed
776
+ * @property {string | string[]} [extension] - Allowed file extension(s)
777
+ * @property {string[]} [extensionBlacklist] - File extensions that are not allowed
778
+ * @property {RegExp | string} [namePattern] - Pattern that file name must match
779
+ * @property {RegExp | string | Array<RegExp | string>} [nameBlacklist] - Pattern(s) that file name must not match
780
+ * @property {boolean} [imageOnly=false] - If true, only allow image files
781
+ * @property {boolean} [documentOnly=false] - If true, only allow document files
782
+ * @property {boolean} [videoOnly=false] - If true, only allow video files
783
+ * @property {boolean} [audioOnly=false] - If true, only allow audio files
784
+ * @property {boolean} [archiveOnly=false] - If true, only allow archive files
785
+ * @property {boolean} [caseSensitive=false] - Whether extension matching is case-sensitive
786
+ * @property {Function} [transform] - Custom transformation function for File objects
787
+ * @property {File | null} [defaultValue] - Default value when input is empty
788
+ * @property {Record<Locale, FileMessages>} [i18n] - Custom error messages for different locales
789
+ */
790
+ type FileOptions<IsRequired extends boolean = true> = {
22
791
  required?: IsRequired;
23
- min?: number;
24
- max?: number;
25
- includes?: string;
792
+ maxSize?: number;
793
+ minSize?: number;
794
+ type?: string | string[];
795
+ typeBlacklist?: string[];
796
+ extension?: string | string[];
797
+ extensionBlacklist?: string[];
798
+ namePattern?: RegExp | string;
799
+ nameBlacklist?: RegExp | string | Array<RegExp | string>;
800
+ imageOnly?: boolean;
801
+ documentOnly?: boolean;
802
+ videoOnly?: boolean;
803
+ audioOnly?: boolean;
804
+ archiveOnly?: boolean;
805
+ caseSensitive?: boolean;
806
+ transform?: (value: File) => File;
807
+ defaultValue?: IsRequired extends true ? File : File | null;
808
+ i18n?: Record<Locale, FileMessages>;
26
809
  };
27
- type UrlSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
28
- declare function url<IsRequired extends boolean = true>(options?: UrlOptions<IsRequired>): UrlSchema<IsRequired>;
810
+ /**
811
+ * Type alias for file validation schema based on required flag
812
+ *
813
+ * @template IsRequired - Whether the field is required
814
+ * @typedef FileSchema
815
+ * @description Returns ZodType<File> if required, ZodNullable<ZodType<File>> if optional
816
+ */
817
+ type FileSchema<IsRequired extends boolean> = IsRequired extends true ? ZodType<File> : ZodNullable<ZodType<File>>;
818
+ /**
819
+ * Creates a Zod schema for file validation with comprehensive filtering options
820
+ *
821
+ * @template IsRequired - Whether the field is required (affects return type)
822
+ * @param {FileOptions<IsRequired>} [options] - Configuration options for file validation
823
+ * @returns {FileSchema<IsRequired>} Zod schema for file validation
824
+ *
825
+ * @description
826
+ * Creates a comprehensive file validator with MIME type filtering, size validation,
827
+ * extension validation, and extensive customization options.
828
+ *
829
+ * Features:
830
+ * - File size validation (min/max)
831
+ * - MIME type whitelist/blacklist support
832
+ * - File extension whitelist/blacklist support
833
+ * - File name pattern validation
834
+ * - Predefined file category filters (image, document, video, audio, archive)
835
+ * - Case-sensitive/insensitive extension matching
836
+ * - Custom transformation functions
837
+ * - Comprehensive internationalization
838
+ *
839
+ * @example
840
+ * ```typescript
841
+ * // Basic file validation
842
+ * const basicSchema = file()
843
+ * basicSchema.parse(new File(["content"], "test.txt"))
844
+ *
845
+ * // Size restrictions
846
+ * const sizeSchema = file({
847
+ * maxSize: 1024 * 1024, // 1MB
848
+ * minSize: 1024 // 1KB
849
+ * })
850
+ *
851
+ * // Extension restrictions
852
+ * const imageSchema = file({
853
+ * extension: [".jpg", ".png", ".gif"],
854
+ * maxSize: 5 * 1024 * 1024 // 5MB
855
+ * })
856
+ *
857
+ * // MIME type restrictions
858
+ * const documentSchema = file({
859
+ * type: ["application/pdf", "application/msword"],
860
+ * maxSize: 10 * 1024 * 1024 // 10MB
861
+ * })
862
+ *
863
+ * // Image files only
864
+ * const imageOnlySchema = file({ imageOnly: true })
865
+ *
866
+ * // Document files only
867
+ * const docOnlySchema = file({ documentOnly: true })
868
+ *
869
+ * // Name pattern validation
870
+ * const patternSchema = file({
871
+ * namePattern: /^[a-zA-Z0-9_-]+\.(pdf|doc|docx)$/,
872
+ * maxSize: 5 * 1024 * 1024
873
+ * })
874
+ *
875
+ * // Optional with default
876
+ * const optionalSchema = file({
877
+ * required: false,
878
+ * defaultValue: null
879
+ * })
880
+ * ```
881
+ *
882
+ * @throws {z.ZodError} When validation fails with specific error messages
883
+ * @see {@link FileOptions} for all available configuration options
884
+ */
885
+ declare function file<IsRequired extends boolean = true>(options?: FileOptions<IsRequired>): FileSchema<IsRequired>;
29
886
 
30
- type TextOptions<IsRequired extends boolean = true> = {
31
- required?: IsRequired;
32
- min?: number;
33
- max?: number;
887
+ /**
888
+ * @fileoverview ID validator for Zod Kit
889
+ *
890
+ * Provides comprehensive ID validation with support for multiple ID formats,
891
+ * auto-detection, custom patterns, and flexible validation options.
892
+ *
893
+ * @author Ong Hoe Yuan
894
+ * @version 0.0.5
895
+ */
896
+
897
+ /**
898
+ * Type definition for ID validation error messages
899
+ *
900
+ * @interface IdMessages
901
+ * @property {string} [required] - Message when field is required but empty
902
+ * @property {string} [invalid] - Message when ID format is invalid
903
+ * @property {string} [minLength] - Message when ID is too short
904
+ * @property {string} [maxLength] - Message when ID is too long
905
+ * @property {string} [numeric] - Message when numeric ID format is invalid
906
+ * @property {string} [uuid] - Message when UUID format is invalid
907
+ * @property {string} [objectId] - Message when MongoDB ObjectId format is invalid
908
+ * @property {string} [nanoid] - Message when Nano ID format is invalid
909
+ * @property {string} [snowflake] - Message when Snowflake ID format is invalid
910
+ * @property {string} [cuid] - Message when CUID format is invalid
911
+ * @property {string} [ulid] - Message when ULID format is invalid
912
+ * @property {string} [shortid] - Message when ShortId format is invalid
913
+ * @property {string} [customFormat] - Message when custom regex format is invalid
914
+ * @property {string} [includes] - Message when ID doesn't contain required string
915
+ * @property {string} [excludes] - Message when ID contains forbidden string
916
+ * @property {string} [startsWith] - Message when ID doesn't start with required string
917
+ * @property {string} [endsWith] - Message when ID doesn't end with required string
918
+ */
919
+ type IdMessages = {
920
+ required?: string;
921
+ invalid?: string;
922
+ minLength?: string;
923
+ maxLength?: string;
924
+ numeric?: string;
925
+ uuid?: string;
926
+ objectId?: string;
927
+ nanoid?: string;
928
+ snowflake?: string;
929
+ cuid?: string;
930
+ ulid?: string;
931
+ shortid?: string;
932
+ customFormat?: string;
933
+ includes?: string;
934
+ excludes?: string;
34
935
  startsWith?: string;
35
936
  endsWith?: string;
937
+ };
938
+ /**
939
+ * Supported ID types for validation
940
+ *
941
+ * @typedef {string} IdType
942
+ *
943
+ * Available types:
944
+ * - numeric: Pure numeric IDs (1, 123, 999999)
945
+ * - uuid: UUID v4 format (xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx)
946
+ * - objectId: MongoDB ObjectId (24-character hexadecimal)
947
+ * - nanoid: Nano ID format (21-character URL-safe)
948
+ * - snowflake: Twitter Snowflake (19-digit number)
949
+ * - cuid: CUID format (25-character starting with 'c')
950
+ * - ulid: ULID format (26-character case-insensitive)
951
+ * - shortid: ShortId format (7-14 character URL-safe)
952
+ * - auto: Auto-detect format from the value
953
+ */
954
+ type IdType = "numeric" | "uuid" | "objectId" | "nanoid" | "snowflake" | "cuid" | "ulid" | "shortid" | "auto";
955
+ /**
956
+ * Configuration options for ID validation
957
+ *
958
+ * @template IsRequired - Whether the field is required (affects return type)
959
+ *
960
+ * @interface IdOptions
961
+ * @property {IsRequired} [required=true] - Whether the field is required
962
+ * @property {IdType} [type="auto"] - Expected ID type or auto-detection
963
+ * @property {number} [minLength] - Minimum length of ID
964
+ * @property {number} [maxLength] - Maximum length of ID
965
+ * @property {IdType[]} [allowedTypes] - Multiple allowed ID types (overrides type)
966
+ * @property {RegExp} [customRegex] - Custom regex pattern (overrides type validation)
967
+ * @property {string} [includes] - String that must be included in ID
968
+ * @property {string | string[]} [excludes] - String(s) that must not be included
969
+ * @property {string} [startsWith] - String that ID must start with
970
+ * @property {string} [endsWith] - String that ID must end with
971
+ * @property {boolean} [caseSensitive=true] - Whether validation is case-sensitive
972
+ * @property {Function} [transform] - Custom transformation function for ID
973
+ * @property {string | null} [defaultValue] - Default value when input is empty
974
+ * @property {Record<Locale, IdMessages>} [i18n] - Custom error messages for different locales
975
+ */
976
+ type IdOptions<IsRequired extends boolean = true> = {
977
+ required?: IsRequired;
978
+ type?: IdType;
979
+ minLength?: number;
980
+ maxLength?: number;
981
+ allowedTypes?: IdType[];
982
+ customRegex?: RegExp;
36
983
  includes?: string;
37
- regex?: RegExp;
984
+ excludes?: string | string[];
985
+ startsWith?: string;
986
+ endsWith?: string;
987
+ caseSensitive?: boolean;
988
+ transform?: (value: string) => string;
38
989
  defaultValue?: IsRequired extends true ? string : string | null;
990
+ i18n?: Record<Locale, IdMessages>;
39
991
  };
40
- type TextSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
41
- declare function text<IsRequired extends boolean = true>(options?: TextOptions<IsRequired>): TextSchema<IsRequired>;
992
+ /**
993
+ * Type alias for ID validation schema based on required flag
994
+ *
995
+ * @template IsRequired - Whether the field is required
996
+ * @typedef IdSchema
997
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
998
+ */
999
+ type IdSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
1000
+ /**
1001
+ * Regular expression patterns for different ID formats
1002
+ *
1003
+ * @constant {Record<string, RegExp>} ID_PATTERNS
1004
+ * @description Maps each ID type to its corresponding regex pattern
1005
+ */
1006
+ declare const ID_PATTERNS: {
1007
+ readonly numeric: RegExp;
1008
+ readonly uuid: RegExp;
1009
+ readonly objectId: RegExp;
1010
+ readonly nanoid: RegExp;
1011
+ readonly snowflake: RegExp;
1012
+ readonly cuid: RegExp;
1013
+ readonly ulid: RegExp;
1014
+ readonly shortid: RegExp;
1015
+ };
1016
+ /**
1017
+ * Detects the ID type of a given value using pattern matching
1018
+ *
1019
+ * @param {string} value - The ID value to analyze
1020
+ * @returns {IdType | null} The detected ID type or null if no pattern matches
1021
+ *
1022
+ * @description
1023
+ * Attempts to identify the ID type by testing against known patterns.
1024
+ * Patterns are ordered by specificity to avoid false positives.
1025
+ * More specific patterns (UUID, ObjectId) are tested before generic ones (numeric, shortid).
1026
+ *
1027
+ * @example
1028
+ * ```typescript
1029
+ * detectIdType("550e8400-e29b-41d4-a716-446655440000") // "uuid"
1030
+ * detectIdType("507f1f77bcf86cd799439011") // "objectId"
1031
+ * detectIdType("V1StGXR8_Z5jdHi6B-myT") // "nanoid"
1032
+ * detectIdType("123456789") // "numeric"
1033
+ * detectIdType("invalid-id") // null
1034
+ * ```
1035
+ */
1036
+ declare const detectIdType: (value: string) => IdType | null;
1037
+ /**
1038
+ * Validates if a value matches the specified ID type
1039
+ *
1040
+ * @param {string} value - The ID value to validate
1041
+ * @param {IdType} type - The expected ID type
1042
+ * @returns {boolean} True if the value matches the specified type
1043
+ *
1044
+ * @description
1045
+ * Validates a specific ID type using regex patterns or auto-detection.
1046
+ * For "auto" type, uses detectIdType to check if any known pattern matches.
1047
+ *
1048
+ * @example
1049
+ * ```typescript
1050
+ * validateIdType("123456", "numeric") // true
1051
+ * validateIdType("abc123", "numeric") // false
1052
+ * validateIdType("550e8400-e29b-41d4-a716-446655440000", "uuid") // true
1053
+ * validateIdType("invalid-uuid", "uuid") // false
1054
+ * ```
1055
+ */
1056
+ declare const validateIdType: (value: string, type: IdType) => boolean;
1057
+ /**
1058
+ * Creates a Zod schema for ID validation with comprehensive format support
1059
+ *
1060
+ * @template IsRequired - Whether the field is required (affects return type)
1061
+ * @param {IdOptions<IsRequired>} [options] - Configuration options for ID validation
1062
+ * @returns {IdSchema<IsRequired>} Zod schema for ID validation
1063
+ *
1064
+ * @description
1065
+ * Creates a comprehensive ID validator with support for multiple ID formats,
1066
+ * auto-detection, custom patterns, and flexible validation options.
1067
+ *
1068
+ * Features:
1069
+ * - Multiple ID format support (UUID, ObjectId, Snowflake, etc.)
1070
+ * - Auto-detection of ID types
1071
+ * - Custom regex pattern support
1072
+ * - Length validation
1073
+ * - Content validation (includes, excludes, startsWith, endsWith)
1074
+ * - Case sensitivity control
1075
+ * - Multiple allowed types
1076
+ * - Custom transformation functions
1077
+ * - Comprehensive internationalization
1078
+ *
1079
+ * @example
1080
+ * ```typescript
1081
+ * // Auto-detect ID format
1082
+ * const autoSchema = id()
1083
+ * autoSchema.parse("550e8400-e29b-41d4-a716-446655440000") // ✓ Valid (UUID)
1084
+ * autoSchema.parse("507f1f77bcf86cd799439011") // ✓ Valid (ObjectId)
1085
+ * autoSchema.parse("123456") // ✓ Valid (numeric)
1086
+ *
1087
+ * // Specific ID type
1088
+ * const uuidSchema = id({ type: "uuid" })
1089
+ * uuidSchema.parse("550e8400-e29b-41d4-a716-446655440000") // ✓ Valid
1090
+ * uuidSchema.parse("invalid-uuid") // ✗ Invalid
1091
+ *
1092
+ * // Multiple allowed types
1093
+ * const multiSchema = id({ allowedTypes: ["uuid", "objectId"] })
1094
+ * multiSchema.parse("550e8400-e29b-41d4-a716-446655440000") // ✓ Valid (UUID)
1095
+ * multiSchema.parse("507f1f77bcf86cd799439011") // ✓ Valid (ObjectId)
1096
+ * multiSchema.parse("123456") // ✗ Invalid (numeric not allowed)
1097
+ *
1098
+ * // Custom regex pattern
1099
+ * const customSchema = id({ customRegex: /^CUST_\d{6}$/ })
1100
+ * customSchema.parse("CUST_123456") // ✓ Valid
1101
+ * customSchema.parse("invalid") // ✗ Invalid
1102
+ *
1103
+ * // Content validation
1104
+ * const prefixSchema = id({
1105
+ * type: "auto",
1106
+ * startsWith: "user_",
1107
+ * minLength: 10
1108
+ * })
1109
+ * prefixSchema.parse("user_123456") // ✓ Valid
1110
+ *
1111
+ * // Case insensitive
1112
+ * const caseInsensitiveSchema = id({
1113
+ * type: "uuid",
1114
+ * caseSensitive: false
1115
+ * })
1116
+ * caseInsensitiveSchema.parse("550E8400-E29B-41D4-A716-446655440000") // ✓ Valid
1117
+ *
1118
+ * // Optional with default
1119
+ * const optionalSchema = id({
1120
+ * required: false,
1121
+ * defaultValue: null
1122
+ * })
1123
+ * ```
1124
+ *
1125
+ * @throws {z.ZodError} When validation fails with specific error messages
1126
+ * @see {@link IdOptions} for all available configuration options
1127
+ * @see {@link IdType} for supported ID types
1128
+ * @see {@link detectIdType} for auto-detection logic
1129
+ * @see {@link validateIdType} for type-specific validation
1130
+ */
1131
+ declare function id<IsRequired extends boolean = true>(options?: IdOptions<IsRequired>): IdSchema<IsRequired>;
42
1132
 
1133
+ /**
1134
+ * @fileoverview Number validator for Zod Kit
1135
+ *
1136
+ * Provides comprehensive number validation with type constraints, range validation,
1137
+ * precision control, and advanced parsing features including comma-separated numbers.
1138
+ *
1139
+ * @author Ong Hoe Yuan
1140
+ * @version 0.0.5
1141
+ */
1142
+
1143
+ /**
1144
+ * Type definition for number validation error messages
1145
+ *
1146
+ * @interface NumberMessages
1147
+ * @property {string} [required] - Message when field is required but empty
1148
+ * @property {string} [invalid] - Message when value is not a valid number
1149
+ * @property {string} [integer] - Message when integer is required but float provided
1150
+ * @property {string} [float] - Message when float is required but integer provided
1151
+ * @property {string} [min] - Message when number is below minimum value
1152
+ * @property {string} [max] - Message when number exceeds maximum value
1153
+ * @property {string} [positive] - Message when positive number is required
1154
+ * @property {string} [negative] - Message when negative number is required
1155
+ * @property {string} [nonNegative] - Message when non-negative number is required
1156
+ * @property {string} [nonPositive] - Message when non-positive number is required
1157
+ * @property {string} [multipleOf] - Message when number is not a multiple of specified value
1158
+ * @property {string} [finite] - Message when finite number is required
1159
+ * @property {string} [precision] - Message when number has too many decimal places
1160
+ */
1161
+ type NumberMessages = {
1162
+ required?: string;
1163
+ invalid?: string;
1164
+ integer?: string;
1165
+ float?: string;
1166
+ min?: string;
1167
+ max?: string;
1168
+ positive?: string;
1169
+ negative?: string;
1170
+ nonNegative?: string;
1171
+ nonPositive?: string;
1172
+ multipleOf?: string;
1173
+ finite?: string;
1174
+ precision?: string;
1175
+ };
1176
+ /**
1177
+ * Configuration options for number validation
1178
+ *
1179
+ * @template IsRequired - Whether the field is required (affects return type)
1180
+ *
1181
+ * @interface NumberOptions
1182
+ * @property {IsRequired} [required=true] - Whether the field is required
1183
+ * @property {number} [min] - Minimum allowed value
1184
+ * @property {number} [max] - Maximum allowed value
1185
+ * @property {number | null} [defaultValue] - Default value when input is empty
1186
+ * @property {"integer" | "float" | "both"} [type="both"] - Type constraint for the number
1187
+ * @property {boolean} [positive] - Whether number must be positive (> 0)
1188
+ * @property {boolean} [negative] - Whether number must be negative (< 0)
1189
+ * @property {boolean} [nonNegative] - Whether number must be non-negative (>= 0)
1190
+ * @property {boolean} [nonPositive] - Whether number must be non-positive (<= 0)
1191
+ * @property {number} [multipleOf] - Number must be a multiple of this value
1192
+ * @property {number} [precision] - Maximum number of decimal places allowed
1193
+ * @property {boolean} [finite=true] - Whether to reject Infinity and -Infinity
1194
+ * @property {Function} [transform] - Custom transformation function for number values
1195
+ * @property {boolean} [parseCommas=false] - Whether to parse comma-separated numbers (e.g., "1,234")
1196
+ * @property {Record<Locale, NumberMessages>} [i18n] - Custom error messages for different locales
1197
+ */
43
1198
  type NumberOptions<IsRequired extends boolean = true> = {
44
1199
  required?: IsRequired;
45
1200
  min?: number;
46
1201
  max?: number;
47
1202
  defaultValue?: IsRequired extends true ? number : number | null;
1203
+ type?: "integer" | "float" | "both";
1204
+ positive?: boolean;
1205
+ negative?: boolean;
1206
+ nonNegative?: boolean;
1207
+ nonPositive?: boolean;
1208
+ multipleOf?: number;
1209
+ precision?: number;
1210
+ finite?: boolean;
1211
+ transform?: (value: number) => number;
1212
+ parseCommas?: boolean;
1213
+ i18n?: Record<Locale, NumberMessages>;
48
1214
  };
1215
+ /**
1216
+ * Type alias for number validation schema based on required flag
1217
+ *
1218
+ * @template IsRequired - Whether the field is required
1219
+ * @typedef NumberSchema
1220
+ * @description Returns ZodNumber if required, ZodNullable<ZodNumber> if optional
1221
+ */
49
1222
  type NumberSchema<IsRequired extends boolean> = IsRequired extends true ? ZodNumber : ZodNullable<ZodNumber>;
1223
+ /**
1224
+ * Creates a Zod schema for number validation with comprehensive constraints
1225
+ *
1226
+ * @template IsRequired - Whether the field is required (affects return type)
1227
+ * @param {NumberOptions<IsRequired>} [options] - Configuration options for number validation
1228
+ * @returns {NumberSchema<IsRequired>} Zod schema for number validation
1229
+ *
1230
+ * @description
1231
+ * Creates a comprehensive number validator with type constraints, range validation,
1232
+ * precision control, and advanced parsing features including comma-separated numbers.
1233
+ *
1234
+ * Features:
1235
+ * - Type constraints (integer, float, or both)
1236
+ * - Range validation (min/max)
1237
+ * - Sign constraints (positive, negative, non-negative, non-positive)
1238
+ * - Multiple-of validation
1239
+ * - Precision control (decimal places)
1240
+ * - Finite number validation
1241
+ * - Comma-separated number parsing
1242
+ * - Custom transformation functions
1243
+ * - Comprehensive internationalization
1244
+ *
1245
+ * @example
1246
+ * ```typescript
1247
+ * // Basic number validation
1248
+ * const basicSchema = number()
1249
+ * basicSchema.parse(42) // ✓ Valid
1250
+ * basicSchema.parse("42") // ✓ Valid (converted to number)
1251
+ *
1252
+ * // Integer only
1253
+ * const integerSchema = number({ type: "integer" })
1254
+ * integerSchema.parse(42) // ✓ Valid
1255
+ * integerSchema.parse(42.5) // ✗ Invalid
1256
+ *
1257
+ * // Range validation
1258
+ * const rangeSchema = number({ min: 0, max: 100 })
1259
+ * rangeSchema.parse(50) // ✓ Valid
1260
+ * rangeSchema.parse(150) // ✗ Invalid
1261
+ *
1262
+ * // Positive numbers only
1263
+ * const positiveSchema = number({ positive: true })
1264
+ * positiveSchema.parse(5) // ✓ Valid
1265
+ * positiveSchema.parse(-5) // ✗ Invalid
1266
+ *
1267
+ * // Multiple of constraint
1268
+ * const multipleSchema = number({ multipleOf: 5 })
1269
+ * multipleSchema.parse(10) // ✓ Valid
1270
+ * multipleSchema.parse(7) // ✗ Invalid
1271
+ *
1272
+ * // Precision control
1273
+ * const precisionSchema = number({ precision: 2 })
1274
+ * precisionSchema.parse(3.14) // ✓ Valid
1275
+ * precisionSchema.parse(3.14159) // ✗ Invalid
1276
+ *
1277
+ * // Comma-separated parsing
1278
+ * const commaSchema = number({ parseCommas: true })
1279
+ * commaSchema.parse("1,234.56") // ✓ Valid (parsed as 1234.56)
1280
+ *
1281
+ * // Optional with default
1282
+ * const optionalSchema = number({
1283
+ * required: false,
1284
+ * defaultValue: 0
1285
+ * })
1286
+ * ```
1287
+ *
1288
+ * @throws {z.ZodError} When validation fails with specific error messages
1289
+ * @see {@link NumberOptions} for all available configuration options
1290
+ */
50
1291
  declare function number<IsRequired extends boolean = true>(options?: NumberOptions<IsRequired>): NumberSchema<IsRequired>;
51
1292
 
1293
+ /**
1294
+ * @fileoverview Password validator for Zod Kit
1295
+ *
1296
+ * Provides comprehensive password validation with strength analysis, character requirements,
1297
+ * security checks, and protection against common weak passwords.
1298
+ *
1299
+ * @author Ong Hoe Yuan
1300
+ * @version 0.0.5
1301
+ */
1302
+
1303
+ /**
1304
+ * Type definition for password validation error messages
1305
+ *
1306
+ * @interface PasswordMessages
1307
+ * @property {string} [required] - Message when field is required but empty
1308
+ * @property {string} [min] - Message when password is too short
1309
+ * @property {string} [max] - Message when password is too long
1310
+ * @property {string} [uppercase] - Message when uppercase letters are required
1311
+ * @property {string} [lowercase] - Message when lowercase letters are required
1312
+ * @property {string} [digits] - Message when digits are required
1313
+ * @property {string} [special] - Message when special characters are required
1314
+ * @property {string} [noRepeating] - Message when repeating characters are forbidden
1315
+ * @property {string} [noSequential] - Message when sequential characters are forbidden
1316
+ * @property {string} [noCommonWords] - Message when common passwords are forbidden
1317
+ * @property {string} [minStrength] - Message when password strength is insufficient
1318
+ * @property {string} [excludes] - Message when password contains forbidden strings
1319
+ * @property {string} [includes] - Message when password doesn't contain required string
1320
+ * @property {string} [invalid] - Message when password doesn't match custom regex
1321
+ */
1322
+ type PasswordMessages = {
1323
+ required?: string;
1324
+ min?: string;
1325
+ max?: string;
1326
+ uppercase?: string;
1327
+ lowercase?: string;
1328
+ digits?: string;
1329
+ special?: string;
1330
+ noRepeating?: string;
1331
+ noSequential?: string;
1332
+ noCommonWords?: string;
1333
+ minStrength?: string;
1334
+ excludes?: string;
1335
+ includes?: string;
1336
+ invalid?: string;
1337
+ };
1338
+ /**
1339
+ * Password strength levels used for validation
1340
+ *
1341
+ * @typedef {"weak" | "medium" | "strong" | "very-strong"} PasswordStrength
1342
+ * @description
1343
+ * - weak: Basic passwords with minimal requirements
1344
+ * - medium: Passwords with some character variety
1345
+ * - strong: Passwords with good character variety and length
1346
+ * - very-strong: Passwords with excellent character variety, length, and complexity
1347
+ */
1348
+ type PasswordStrength = "weak" | "medium" | "strong" | "very-strong";
1349
+ /**
1350
+ * Configuration options for password validation
1351
+ *
1352
+ * @template IsRequired - Whether the field is required (affects return type)
1353
+ *
1354
+ * @interface PasswordOptions
1355
+ * @property {IsRequired} [required=true] - Whether the field is required
1356
+ * @property {number} [min] - Minimum length of password
1357
+ * @property {number} [max] - Maximum length of password
1358
+ * @property {boolean} [uppercase] - Whether uppercase letters are required
1359
+ * @property {boolean} [lowercase] - Whether lowercase letters are required
1360
+ * @property {boolean} [digits] - Whether digits are required
1361
+ * @property {boolean} [special] - Whether special characters are required
1362
+ * @property {boolean} [noRepeating] - Whether to forbid repeating characters (3+ in a row)
1363
+ * @property {boolean} [noSequential] - Whether to forbid sequential characters (abc, 123)
1364
+ * @property {boolean} [noCommonWords] - Whether to forbid common weak passwords
1365
+ * @property {PasswordStrength} [minStrength] - Minimum required password strength
1366
+ * @property {string | string[]} [excludes] - String(s) that must not be included
1367
+ * @property {string} [includes] - String that must be included in password
1368
+ * @property {RegExp} [regex] - Custom regex pattern for validation
1369
+ * @property {Function} [transform] - Custom transformation function for password
1370
+ * @property {string | null} [defaultValue] - Default value when input is empty
1371
+ * @property {Record<Locale, PasswordMessages>} [i18n] - Custom error messages for different locales
1372
+ */
52
1373
  type PasswordOptions<IsRequired extends boolean = true> = {
53
1374
  required?: IsRequired;
54
1375
  min?: number;
@@ -57,21 +1378,1696 @@ type PasswordOptions<IsRequired extends boolean = true> = {
57
1378
  lowercase?: boolean;
58
1379
  digits?: boolean;
59
1380
  special?: boolean;
1381
+ noRepeating?: boolean;
1382
+ noSequential?: boolean;
1383
+ noCommonWords?: boolean;
1384
+ minStrength?: PasswordStrength;
1385
+ excludes?: string | string[];
1386
+ includes?: string;
1387
+ regex?: RegExp;
1388
+ transform?: (value: string) => string;
1389
+ defaultValue?: IsRequired extends true ? string : string | null;
1390
+ i18n?: Record<Locale, PasswordMessages>;
60
1391
  };
1392
+ /**
1393
+ * Type alias for password validation schema based on required flag
1394
+ *
1395
+ * @template IsRequired - Whether the field is required
1396
+ * @typedef PasswordSchema
1397
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
1398
+ */
61
1399
  type PasswordSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
1400
+ /**
1401
+ * Creates a Zod schema for password validation with comprehensive security checks
1402
+ *
1403
+ * @template IsRequired - Whether the field is required (affects return type)
1404
+ * @param {PasswordOptions<IsRequired>} [options] - Configuration options for password validation
1405
+ * @returns {PasswordSchema<IsRequired>} Zod schema for password validation
1406
+ *
1407
+ * @description
1408
+ * Creates a comprehensive password validator with strength analysis, character requirements,
1409
+ * security checks, and protection against common weak passwords.
1410
+ *
1411
+ * Features:
1412
+ * - Length validation (min/max)
1413
+ * - Character requirements (uppercase, lowercase, digits, special)
1414
+ * - Security checks (no repeating, no sequential patterns)
1415
+ * - Common password detection
1416
+ * - Strength analysis with configurable minimum levels
1417
+ * - Content inclusion/exclusion
1418
+ * - Custom regex patterns
1419
+ * - Custom transformation functions
1420
+ * - Comprehensive internationalization
1421
+ *
1422
+ * @example
1423
+ * ```typescript
1424
+ * // Basic password validation
1425
+ * const basicSchema = password()
1426
+ * basicSchema.parse("MyPassword123!") // ✓ Valid
1427
+ *
1428
+ * // Strong password requirements
1429
+ * const strongSchema = password({
1430
+ * min: 12,
1431
+ * uppercase: true,
1432
+ * lowercase: true,
1433
+ * digits: true,
1434
+ * special: true,
1435
+ * minStrength: "strong"
1436
+ * })
1437
+ *
1438
+ * // No common passwords
1439
+ * const secureSchema = password({
1440
+ * noCommonWords: true,
1441
+ * noRepeating: true,
1442
+ * noSequential: true
1443
+ * })
1444
+ * secureSchema.parse("password123") // ✗ Invalid (common password)
1445
+ * secureSchema.parse("aaa123") // ✗ Invalid (repeating characters)
1446
+ * secureSchema.parse("abc123") // ✗ Invalid (sequential characters)
1447
+ *
1448
+ * // Custom requirements
1449
+ * const customSchema = password({
1450
+ * min: 8,
1451
+ * includes: "@", // Must contain @
1452
+ * excludes: ["admin", "user"], // Cannot contain these words
1453
+ * regex: /^(?=.*[A-Z])(?=.*[a-z])(?=.*\d)/ // Custom pattern
1454
+ * })
1455
+ *
1456
+ * // Minimum strength requirement
1457
+ * const strengthSchema = password({ minStrength: "very-strong" })
1458
+ * strengthSchema.parse("weak") // ✗ Invalid (insufficient strength)
1459
+ * strengthSchema.parse("MyVeryStr0ng!P@ssw0rd2024") // ✓ Valid
1460
+ *
1461
+ * // Optional with default
1462
+ * const optionalSchema = password({
1463
+ * required: false,
1464
+ * defaultValue: null
1465
+ * })
1466
+ * ```
1467
+ *
1468
+ * @throws {z.ZodError} When validation fails with specific error messages
1469
+ * @see {@link PasswordOptions} for all available configuration options
1470
+ * @see {@link PasswordStrength} for strength level definitions
1471
+ * @see {@link calculatePasswordStrength} for strength calculation logic
1472
+ */
62
1473
  declare function password<IsRequired extends boolean = true>(options?: PasswordOptions<IsRequired>): PasswordSchema<IsRequired>;
63
1474
 
64
- type IntegerOptions<IsRequired extends boolean = true> = {
1475
+ /**
1476
+ * @fileoverview Text validator for Zod Kit
1477
+ *
1478
+ * Provides comprehensive text validation with length constraints, content validation,
1479
+ * flexible trimming and casing options, and advanced transformation features.
1480
+ *
1481
+ * @author Ong Hoe Yuan
1482
+ * @version 0.0.5
1483
+ */
1484
+
1485
+ /**
1486
+ * Type definition for text validation error messages
1487
+ *
1488
+ * @interface TextMessages
1489
+ * @property {string} [required] - Message when field is required but empty
1490
+ * @property {string} [notEmpty] - Message when field must not be empty (whitespace-only)
1491
+ * @property {string} [minLength] - Message when text is shorter than minimum length
1492
+ * @property {string} [maxLength] - Message when text exceeds maximum length
1493
+ * @property {string} [startsWith] - Message when text doesn't start with required string
1494
+ * @property {string} [endsWith] - Message when text doesn't end with required string
1495
+ * @property {string} [includes] - Message when text doesn't contain required string
1496
+ * @property {string} [excludes] - Message when text contains forbidden string
1497
+ * @property {string} [invalid] - Message when text doesn't match regex pattern
1498
+ */
1499
+ type TextMessages = {
1500
+ required?: string;
1501
+ notEmpty?: string;
1502
+ minLength?: string;
1503
+ maxLength?: string;
1504
+ startsWith?: string;
1505
+ endsWith?: string;
1506
+ includes?: string;
1507
+ excludes?: string;
1508
+ invalid?: string;
1509
+ };
1510
+ /**
1511
+ * Configuration options for text validation
1512
+ *
1513
+ * @template IsRequired - Whether the field is required (affects return type)
1514
+ *
1515
+ * @interface TextOptions
1516
+ * @property {IsRequired} [required=true] - Whether the field is required
1517
+ * @property {number} [minLength] - Minimum length of text
1518
+ * @property {number} [maxLength] - Maximum length of text
1519
+ * @property {string} [startsWith] - String that text must start with
1520
+ * @property {string} [endsWith] - String that text must end with
1521
+ * @property {string} [includes] - String that must be included in text
1522
+ * @property {string | string[]} [excludes] - String(s) that must not be included
1523
+ * @property {RegExp} [regex] - Regular expression pattern for validation
1524
+ * @property {"trim" | "trimStart" | "trimEnd" | "none"} [trimMode="trim"] - Whitespace handling
1525
+ * @property {"upper" | "lower" | "title" | "none"} [casing="none"] - Case transformation
1526
+ * @property {Function} [transform] - Custom transformation function for text
1527
+ * @property {boolean} [notEmpty] - Whether to reject whitespace-only strings
1528
+ * @property {string | null} [defaultValue] - Default value when input is empty
1529
+ * @property {Record<Locale, TextMessages>} [i18n] - Custom error messages for different locales
1530
+ */
1531
+ type TextOptions<IsRequired extends boolean = true> = {
1532
+ required?: IsRequired;
1533
+ minLength?: number;
1534
+ maxLength?: number;
1535
+ startsWith?: string;
1536
+ endsWith?: string;
1537
+ includes?: string;
1538
+ excludes?: string | string[];
1539
+ regex?: RegExp;
1540
+ trimMode?: "trim" | "trimStart" | "trimEnd" | "none";
1541
+ casing?: "upper" | "lower" | "title" | "none";
1542
+ transform?: (value: string) => string;
1543
+ notEmpty?: boolean;
1544
+ defaultValue?: IsRequired extends true ? string : string | null;
1545
+ i18n?: Record<Locale, TextMessages>;
1546
+ };
1547
+ /**
1548
+ * Type alias for text validation schema based on required flag
1549
+ *
1550
+ * @template IsRequired - Whether the field is required
1551
+ * @typedef TextSchema
1552
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
1553
+ */
1554
+ type TextSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
1555
+ /**
1556
+ * Creates a Zod schema for text validation with comprehensive string processing
1557
+ *
1558
+ * @template IsRequired - Whether the field is required (affects return type)
1559
+ * @param {TextOptions<IsRequired>} [options] - Configuration options for text validation
1560
+ * @returns {TextSchema<IsRequired>} Zod schema for text validation
1561
+ *
1562
+ * @description
1563
+ * Creates a comprehensive text validator with length constraints, content validation,
1564
+ * flexible trimming and casing options, and advanced transformation features.
1565
+ *
1566
+ * Features:
1567
+ * - Length validation (min/max)
1568
+ * - Content validation (startsWith, endsWith, includes, excludes)
1569
+ * - Regular expression pattern matching
1570
+ * - Flexible trimming options (trim, trimStart, trimEnd, none)
1571
+ * - Case transformation (upper, lower, title, none)
1572
+ * - Empty string vs whitespace-only validation
1573
+ * - Custom transformation functions
1574
+ * - Comprehensive internationalization
1575
+ *
1576
+ * @example
1577
+ * ```typescript
1578
+ * // Basic text validation
1579
+ * const basicSchema = text()
1580
+ * basicSchema.parse("Hello World") // ✓ Valid
1581
+ *
1582
+ * // Length constraints
1583
+ * const lengthSchema = text({ minLength: 3, maxLength: 50 })
1584
+ * lengthSchema.parse("Hello") // ✓ Valid
1585
+ * lengthSchema.parse("Hi") // ✗ Invalid (too short)
1586
+ *
1587
+ * // Content validation
1588
+ * const contentSchema = text({
1589
+ * startsWith: "Hello",
1590
+ * endsWith: "!",
1591
+ * includes: "World"
1592
+ * })
1593
+ * contentSchema.parse("Hello World!") // ✓ Valid
1594
+ *
1595
+ * // Case transformation
1596
+ * const upperSchema = text({ casing: "upper" })
1597
+ * upperSchema.parse("hello") // ✓ Valid (converted to "HELLO")
1598
+ *
1599
+ * // Trim modes
1600
+ * const trimStartSchema = text({ trimMode: "trimStart" })
1601
+ * trimStartSchema.parse(" hello ") // ✓ Valid (result: "hello ")
1602
+ *
1603
+ * // Regex validation
1604
+ * const regexSchema = text({ regex: /^[a-zA-Z]+$/ })
1605
+ * regexSchema.parse("hello") // ✓ Valid
1606
+ * regexSchema.parse("hello123") // ✗ Invalid
1607
+ *
1608
+ * // Not empty (rejects whitespace-only)
1609
+ * const notEmptySchema = text({ notEmpty: true })
1610
+ * notEmptySchema.parse("hello") // ✓ Valid
1611
+ * notEmptySchema.parse(" ") // ✗ Invalid
1612
+ *
1613
+ * // Optional with default
1614
+ * const optionalSchema = text({
1615
+ * required: false,
1616
+ * defaultValue: "default text"
1617
+ * })
1618
+ * ```
1619
+ *
1620
+ * @throws {z.ZodError} When validation fails with specific error messages
1621
+ * @see {@link TextOptions} for all available configuration options
1622
+ */
1623
+ declare function text<IsRequired extends boolean = true>(options?: TextOptions<IsRequired>): TextSchema<IsRequired>;
1624
+
1625
+ /**
1626
+ * @fileoverview Time validator for Zod Kit
1627
+ *
1628
+ * Provides comprehensive time validation with support for multiple time formats,
1629
+ * hour/minute constraints, and advanced time-based validation options.
1630
+ *
1631
+ * @author Ong Hoe Yuan
1632
+ * @version 0.0.5
1633
+ */
1634
+
1635
+ /**
1636
+ * Type definition for time validation error messages
1637
+ *
1638
+ * @interface TimeMessages
1639
+ * @property {string} [required] - Message when field is required but empty
1640
+ * @property {string} [invalid] - Message when time format is invalid
1641
+ * @property {string} [format] - Message when time doesn't match expected format
1642
+ * @property {string} [min] - Message when time is before minimum allowed
1643
+ * @property {string} [max] - Message when time is after maximum allowed
1644
+ * @property {string} [hour] - Message when hour is outside allowed range
1645
+ * @property {string} [minute] - Message when minute doesn't match step requirement
1646
+ * @property {string} [second] - Message when second doesn't match step requirement
1647
+ * @property {string} [includes] - Message when time doesn't contain required string
1648
+ * @property {string} [excludes] - Message when time contains forbidden string
1649
+ * @property {string} [customRegex] - Message when custom regex validation fails
1650
+ * @property {string} [notInWhitelist] - Message when value is not in whitelist
1651
+ */
1652
+ type TimeMessages = {
1653
+ required?: string;
1654
+ invalid?: string;
1655
+ format?: string;
1656
+ min?: string;
1657
+ max?: string;
1658
+ hour?: string;
1659
+ minute?: string;
1660
+ second?: string;
1661
+ includes?: string;
1662
+ excludes?: string;
1663
+ customRegex?: string;
1664
+ notInWhitelist?: string;
1665
+ };
1666
+ /**
1667
+ * Supported time formats for validation
1668
+ *
1669
+ * @typedef {string} TimeFormat
1670
+ *
1671
+ * Available formats:
1672
+ * - HH:mm: 24-hour format with leading zeros (14:30, 09:30)
1673
+ * - HH:mm:ss: 24-hour format with seconds (14:30:45, 09:30:15)
1674
+ * - hh:mm A: 12-hour format with AM/PM (02:30 PM, 09:30 AM)
1675
+ * - hh:mm:ss A: 12-hour format with seconds and AM/PM (02:30:45 PM)
1676
+ * - H:mm: 24-hour format without leading zeros (14:30, 9:30)
1677
+ * - h:mm A: 12-hour format without leading zeros (2:30 PM, 9:30 AM)
1678
+ */
1679
+ type TimeFormat = "HH:mm" | "HH:mm:ss" | "hh:mm A" | "hh:mm:ss A" | "H:mm" | "h:mm A";
1680
+ /**
1681
+ * Configuration options for time validation
1682
+ *
1683
+ * @template IsRequired - Whether the field is required (affects return type)
1684
+ *
1685
+ * @interface TimeOptions
1686
+ * @property {IsRequired} [required=true] - Whether the field is required
1687
+ * @property {TimeFormat} [format="HH:mm"] - Expected time format
1688
+ * @property {string} [min] - Minimum allowed time (e.g., "09:00")
1689
+ * @property {string} [max] - Maximum allowed time (e.g., "17:00")
1690
+ * @property {number} [minHour] - Minimum allowed hour (0-23)
1691
+ * @property {number} [maxHour] - Maximum allowed hour (0-23)
1692
+ * @property {number[]} [allowedHours] - Specific hours that are allowed
1693
+ * @property {number} [minuteStep] - Required minute intervals (e.g., 15 for :00, :15, :30, :45)
1694
+ * @property {number} [secondStep] - Required second intervals
1695
+ * @property {string} [includes] - String that must be included in the time
1696
+ * @property {string | string[]} [excludes] - String(s) that must not be included
1697
+ * @property {RegExp} [regex] - Custom regex for validation (overrides format validation)
1698
+ * @property {"trim" | "trimStart" | "trimEnd" | "none"} [trimMode="trim"] - Whitespace handling
1699
+ * @property {"upper" | "lower" | "none"} [casing="none"] - Case transformation
1700
+ * @property {string[]} [whitelist] - Specific time strings that are always allowed
1701
+ * @property {boolean} [whitelistOnly=false] - If true, only values in whitelist are allowed
1702
+ * @property {Function} [transform] - Custom transformation function applied before validation
1703
+ * @property {string | null} [defaultValue] - Default value when input is empty
1704
+ * @property {Record<Locale, TimeMessages>} [i18n] - Custom error messages for different locales
1705
+ */
1706
+ type TimeOptions<IsRequired extends boolean = true> = {
1707
+ required?: IsRequired;
1708
+ format?: TimeFormat;
1709
+ min?: string;
1710
+ max?: string;
1711
+ minHour?: number;
1712
+ maxHour?: number;
1713
+ allowedHours?: number[];
1714
+ minuteStep?: number;
1715
+ secondStep?: number;
1716
+ includes?: string;
1717
+ excludes?: string | string[];
1718
+ regex?: RegExp;
1719
+ trimMode?: "trim" | "trimStart" | "trimEnd" | "none";
1720
+ casing?: "upper" | "lower" | "none";
1721
+ whitelist?: string[];
1722
+ whitelistOnly?: boolean;
1723
+ transform?: (value: string) => string;
1724
+ defaultValue?: IsRequired extends true ? string : string | null;
1725
+ i18n?: Record<Locale, TimeMessages>;
1726
+ };
1727
+ /**
1728
+ * Type alias for time validation schema based on required flag
1729
+ *
1730
+ * @template IsRequired - Whether the field is required
1731
+ * @typedef TimeSchema
1732
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
1733
+ */
1734
+ type TimeSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
1735
+ /**
1736
+ * Regular expression patterns for time format validation
1737
+ *
1738
+ * @constant {Record<TimeFormat, RegExp>} TIME_PATTERNS
1739
+ * @description Maps each supported time format to its corresponding regex pattern
1740
+ */
1741
+ declare const TIME_PATTERNS: Record<TimeFormat, RegExp>;
1742
+ /**
1743
+ * Parses a time string to minutes since midnight for comparison
1744
+ *
1745
+ * @param {string} timeStr - The time string to parse
1746
+ * @param {TimeFormat} format - The expected time format
1747
+ * @returns {number | null} Minutes since midnight (0-1439) or null if parsing fails
1748
+ *
1749
+ * @description
1750
+ * Converts time strings to minutes since midnight for easy comparison and validation.
1751
+ * Handles both 12-hour and 24-hour formats with proper AM/PM conversion.
1752
+ *
1753
+ * @example
1754
+ * ```typescript
1755
+ * parseTimeToMinutes("14:30", "HH:mm") // 870 (14*60 + 30)
1756
+ * parseTimeToMinutes("2:30 PM", "h:mm A") // 870 (14*60 + 30)
1757
+ * parseTimeToMinutes("12:00 AM", "hh:mm A") // 0 (midnight)
1758
+ * parseTimeToMinutes("12:00 PM", "hh:mm A") // 720 (noon)
1759
+ * ```
1760
+ */
1761
+ declare const parseTimeToMinutes: (timeStr: string, format: TimeFormat) => number | null;
1762
+ /**
1763
+ * Validates if a time string matches the specified format pattern
1764
+ *
1765
+ * @param {string} value - The time string to validate
1766
+ * @param {TimeFormat} format - The expected time format
1767
+ * @returns {boolean} True if the time matches the format pattern
1768
+ *
1769
+ * @description
1770
+ * Performs regex pattern matching to validate time format.
1771
+ * Does not validate actual time values (e.g., 25:00 would pass pattern but fail logic).
1772
+ *
1773
+ * @example
1774
+ * ```typescript
1775
+ * validateTimeFormat("14:30", "HH:mm") // true
1776
+ * validateTimeFormat("2:30 PM", "h:mm A") // true
1777
+ * validateTimeFormat("25:00", "HH:mm") // true (pattern matches)
1778
+ * validateTimeFormat("14:30", "h:mm A") // false (wrong format)
1779
+ * ```
1780
+ */
1781
+ declare const validateTimeFormat: (value: string, format: TimeFormat) => boolean;
1782
+ /**
1783
+ * Normalizes time to 24-hour format for internal processing
1784
+ *
1785
+ * @param {string} timeStr - The time string to normalize
1786
+ * @param {TimeFormat} format - The current time format
1787
+ * @returns {string | null} Normalized time string or null if parsing fails
1788
+ *
1789
+ * @description
1790
+ * Converts time strings to a standardized 24-hour format for consistent processing.
1791
+ * Handles AM/PM conversion and leading zero normalization.
1792
+ *
1793
+ * @example
1794
+ * ```typescript
1795
+ * normalizeTime("2:30 PM", "h:mm A") // "14:30"
1796
+ * normalizeTime("12:00 AM", "hh:mm A") // "00:00"
1797
+ * normalizeTime("9:30", "H:mm") // "09:30"
1798
+ * normalizeTime("14:30:45", "HH:mm:ss") // "14:30:45"
1799
+ * ```
1800
+ */
1801
+ declare const normalizeTime: (timeStr: string, format: TimeFormat) => string | null;
1802
+ /**
1803
+ * Creates a Zod schema for time validation with comprehensive options
1804
+ *
1805
+ * @template IsRequired - Whether the field is required (affects return type)
1806
+ * @param {TimeOptions<IsRequired>} [options] - Configuration options for time validation
1807
+ * @returns {TimeSchema<IsRequired>} Zod schema for time validation
1808
+ *
1809
+ * @description
1810
+ * Creates a comprehensive time validator that supports multiple time formats,
1811
+ * hour/minute constraints, step validation, and extensive customization options.
1812
+ *
1813
+ * Features:
1814
+ * - Multiple time formats (24-hour, 12-hour, with/without seconds)
1815
+ * - Time range validation (min/max)
1816
+ * - Hour and minute constraints
1817
+ * - Step validation (e.g., 15-minute intervals)
1818
+ * - Whitelist/blacklist support
1819
+ * - Custom regex patterns
1820
+ * - String transformation and case handling
1821
+ * - Comprehensive internationalization
1822
+ *
1823
+ * @example
1824
+ * ```typescript
1825
+ * // Basic time validation (24-hour format)
1826
+ * const basicSchema = time()
1827
+ * basicSchema.parse("14:30") // ✓ Valid
1828
+ * basicSchema.parse("2:30 PM") // ✗ Invalid (wrong format)
1829
+ *
1830
+ * // 12-hour format with AM/PM
1831
+ * const ampmSchema = time({ format: "hh:mm A" })
1832
+ * ampmSchema.parse("02:30 PM") // ✓ Valid
1833
+ * ampmSchema.parse("14:30") // ✗ Invalid (wrong format)
1834
+ *
1835
+ * // Business hours validation
1836
+ * const businessHours = time({
1837
+ * format: "HH:mm",
1838
+ * minHour: 9,
1839
+ * maxHour: 17,
1840
+ * minuteStep: 15 // Only :00, :15, :30, :45
1841
+ * })
1842
+ * businessHours.parse("09:15") // ✓ Valid
1843
+ * businessHours.parse("18:00") // ✗ Invalid (after maxHour)
1844
+ * businessHours.parse("09:05") // ✗ Invalid (not 15-minute step)
1845
+ *
1846
+ * // Time range validation
1847
+ * const timeRangeSchema = time({
1848
+ * min: "09:00",
1849
+ * max: "17:00"
1850
+ * })
1851
+ * timeRangeSchema.parse("12:30") // ✓ Valid
1852
+ * timeRangeSchema.parse("08:00") // ✗ Invalid (before min)
1853
+ *
1854
+ * // Allowed hours only
1855
+ * const specificHours = time({
1856
+ * allowedHours: [9, 12, 15, 18]
1857
+ * })
1858
+ * specificHours.parse("12:30") // ✓ Valid
1859
+ * specificHours.parse("11:30") // ✗ Invalid (hour not allowed)
1860
+ *
1861
+ * // Whitelist specific times
1862
+ * const whitelistSchema = time({
1863
+ * whitelist: ["09:00", "12:00", "17:00"],
1864
+ * whitelistOnly: true
1865
+ * })
1866
+ * whitelistSchema.parse("12:00") // ✓ Valid (in whitelist)
1867
+ * whitelistSchema.parse("13:00") // ✗ Invalid (not in whitelist)
1868
+ *
1869
+ * // Optional with default
1870
+ * const optionalSchema = time({
1871
+ * required: false,
1872
+ * defaultValue: "09:00"
1873
+ * })
1874
+ * optionalSchema.parse("") // ✓ Valid (returns "09:00")
1875
+ * ```
1876
+ *
1877
+ * @throws {z.ZodError} When validation fails with specific error messages
1878
+ * @see {@link TimeOptions} for all available configuration options
1879
+ * @see {@link TimeFormat} for supported time formats
1880
+ */
1881
+ declare function time<IsRequired extends boolean = true>(options?: TimeOptions<IsRequired>): TimeSchema<IsRequired>;
1882
+
1883
+ /**
1884
+ * @fileoverview URL validator for Zod Kit
1885
+ *
1886
+ * Provides comprehensive URL validation with protocol filtering, domain control,
1887
+ * port validation, path constraints, and localhost handling.
1888
+ *
1889
+ * @author Ong Hoe Yuan
1890
+ * @version 0.0.5
1891
+ */
1892
+
1893
+ /**
1894
+ * Type definition for URL validation error messages
1895
+ *
1896
+ * @interface UrlMessages
1897
+ * @property {string} [required] - Message when field is required but empty
1898
+ * @property {string} [invalid] - Message when URL format is invalid
1899
+ * @property {string} [min] - Message when URL is too short
1900
+ * @property {string} [max] - Message when URL is too long
1901
+ * @property {string} [includes] - Message when URL doesn't contain required string
1902
+ * @property {string} [excludes] - Message when URL contains forbidden string
1903
+ * @property {string} [protocol] - Message when protocol is not allowed
1904
+ * @property {string} [domain] - Message when domain is not allowed
1905
+ * @property {string} [domainBlacklist] - Message when domain is blacklisted
1906
+ * @property {string} [port] - Message when port is not allowed
1907
+ * @property {string} [pathStartsWith] - Message when path doesn't start with required string
1908
+ * @property {string} [pathEndsWith] - Message when path doesn't end with required string
1909
+ * @property {string} [hasQuery] - Message when query parameters are required
1910
+ * @property {string} [noQuery] - Message when query parameters are forbidden
1911
+ * @property {string} [hasFragment] - Message when fragment is required
1912
+ * @property {string} [noFragment] - Message when fragment is forbidden
1913
+ * @property {string} [localhost] - Message when localhost is forbidden
1914
+ * @property {string} [noLocalhost] - Message when localhost is required
1915
+ */
1916
+ type UrlMessages = {
1917
+ required?: string;
1918
+ invalid?: string;
1919
+ min?: string;
1920
+ max?: string;
1921
+ includes?: string;
1922
+ excludes?: string;
1923
+ protocol?: string;
1924
+ domain?: string;
1925
+ domainBlacklist?: string;
1926
+ port?: string;
1927
+ pathStartsWith?: string;
1928
+ pathEndsWith?: string;
1929
+ hasQuery?: string;
1930
+ noQuery?: string;
1931
+ hasFragment?: string;
1932
+ noFragment?: string;
1933
+ localhost?: string;
1934
+ noLocalhost?: string;
1935
+ };
1936
+ /**
1937
+ * Configuration options for URL validation
1938
+ *
1939
+ * @template IsRequired - Whether the field is required (affects return type)
1940
+ *
1941
+ * @interface UrlOptions
1942
+ * @property {IsRequired} [required=true] - Whether the field is required
1943
+ * @property {number} [min] - Minimum length of URL
1944
+ * @property {number} [max] - Maximum length of URL
1945
+ * @property {string} [includes] - String that must be included in URL
1946
+ * @property {string | string[]} [excludes] - String(s) that must not be included
1947
+ * @property {string[]} [protocols] - Allowed protocols (e.g., ["https", "http"])
1948
+ * @property {string[]} [allowedDomains] - Domains that are allowed
1949
+ * @property {string[]} [blockedDomains] - Domains that are blocked
1950
+ * @property {number[]} [allowedPorts] - Ports that are allowed
1951
+ * @property {number[]} [blockedPorts] - Ports that are blocked
1952
+ * @property {string} [pathStartsWith] - Path must start with this string
1953
+ * @property {string} [pathEndsWith] - Path must end with this string
1954
+ * @property {boolean} [mustHaveQuery] - Whether URL must have query parameters
1955
+ * @property {boolean} [mustNotHaveQuery] - Whether URL must not have query parameters
1956
+ * @property {boolean} [mustHaveFragment] - Whether URL must have fragment
1957
+ * @property {boolean} [mustNotHaveFragment] - Whether URL must not have fragment
1958
+ * @property {boolean} [allowLocalhost=true] - Whether to allow localhost URLs
1959
+ * @property {boolean} [blockLocalhost] - Whether to explicitly block localhost URLs
1960
+ * @property {Function} [transform] - Custom transformation function for URL strings
1961
+ * @property {string | null} [defaultValue] - Default value when input is empty
1962
+ * @property {Record<Locale, UrlMessages>} [i18n] - Custom error messages for different locales
1963
+ */
1964
+ type UrlOptions<IsRequired extends boolean = true> = {
65
1965
  required?: IsRequired;
66
1966
  min?: number;
67
1967
  max?: number;
68
- defaultValue?: IsRequired extends true ? number : number | null;
1968
+ includes?: string;
1969
+ excludes?: string | string[];
1970
+ protocols?: string[];
1971
+ allowedDomains?: string[];
1972
+ blockedDomains?: string[];
1973
+ allowedPorts?: number[];
1974
+ blockedPorts?: number[];
1975
+ pathStartsWith?: string;
1976
+ pathEndsWith?: string;
1977
+ mustHaveQuery?: boolean;
1978
+ mustNotHaveQuery?: boolean;
1979
+ mustHaveFragment?: boolean;
1980
+ mustNotHaveFragment?: boolean;
1981
+ allowLocalhost?: boolean;
1982
+ blockLocalhost?: boolean;
1983
+ transform?: (value: string) => string;
1984
+ defaultValue?: IsRequired extends true ? string : string | null;
1985
+ i18n?: Record<Locale, UrlMessages>;
69
1986
  };
70
- type IntegerSchema<IsRequired extends boolean> = IsRequired extends true ? ZodNumber : ZodNullable<ZodNumber>;
71
- declare function integer<IsRequired extends boolean = true>(options?: IntegerOptions<IsRequired>): IntegerSchema<IsRequired>;
1987
+ /**
1988
+ * Type alias for URL validation schema based on required flag
1989
+ *
1990
+ * @template IsRequired - Whether the field is required
1991
+ * @typedef UrlSchema
1992
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
1993
+ */
1994
+ type UrlSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
1995
+ /**
1996
+ * Creates a Zod schema for URL validation with comprehensive constraints
1997
+ *
1998
+ * @template IsRequired - Whether the field is required (affects return type)
1999
+ * @param {UrlOptions<IsRequired>} [options] - Configuration options for URL validation
2000
+ * @returns {UrlSchema<IsRequired>} Zod schema for URL validation
2001
+ *
2002
+ * @description
2003
+ * Creates a comprehensive URL validator with protocol filtering, domain control,
2004
+ * port validation, path constraints, and localhost handling.
2005
+ *
2006
+ * Features:
2007
+ * - RFC-compliant URL format validation
2008
+ * - Protocol whitelist/blacklist (http, https, ftp, etc.)
2009
+ * - Domain whitelist/blacklist with subdomain support
2010
+ * - Port validation and filtering
2011
+ * - Path prefix/suffix validation
2012
+ * - Query parameter requirements
2013
+ * - Fragment requirements
2014
+ * - Localhost detection and control
2015
+ * - Length validation
2016
+ * - Content inclusion/exclusion
2017
+ * - Custom transformation functions
2018
+ * - Comprehensive internationalization
2019
+ *
2020
+ * @example
2021
+ * ```typescript
2022
+ * // Basic URL validation
2023
+ * const basicSchema = url()
2024
+ * basicSchema.parse("https://example.com") // ✓ Valid
2025
+ *
2026
+ * // HTTPS only
2027
+ * const httpsSchema = url({ protocols: ["https"] })
2028
+ * httpsSchema.parse("https://example.com") // ✓ Valid
2029
+ * httpsSchema.parse("http://example.com") // ✗ Invalid
2030
+ *
2031
+ * // Domain restriction
2032
+ * const domainSchema = url({
2033
+ * allowedDomains: ["company.com", "trusted.org"]
2034
+ * })
2035
+ * domainSchema.parse("https://app.company.com") // ✓ Valid (subdomain)
2036
+ * domainSchema.parse("https://example.com") // ✗ Invalid
2037
+ *
2038
+ * // Block localhost
2039
+ * const noLocalhostSchema = url({ blockLocalhost: true })
2040
+ * noLocalhostSchema.parse("https://example.com") // ✓ Valid
2041
+ * noLocalhostSchema.parse("http://localhost:3000") // ✗ Invalid
2042
+ *
2043
+ * // API endpoints with path requirements
2044
+ * const apiSchema = url({
2045
+ * pathStartsWith: "/api/",
2046
+ * mustHaveQuery: true
2047
+ * })
2048
+ * apiSchema.parse("https://api.com/api/users?page=1") // ✓ Valid
2049
+ *
2050
+ * // Port restrictions
2051
+ * const portSchema = url({
2052
+ * allowedPorts: [80, 443, 8080]
2053
+ * })
2054
+ * portSchema.parse("https://example.com:443") // ✓ Valid
2055
+ * portSchema.parse("https://example.com:3000") // ✗ Invalid
2056
+ *
2057
+ * // Optional with default
2058
+ * const optionalSchema = url({
2059
+ * required: false,
2060
+ * defaultValue: null
2061
+ * })
2062
+ * ```
2063
+ *
2064
+ * @throws {z.ZodError} When validation fails with specific error messages
2065
+ * @see {@link UrlOptions} for all available configuration options
2066
+ */
2067
+ declare function url<IsRequired extends boolean = true>(options?: UrlOptions<IsRequired>): UrlSchema<IsRequired>;
72
2068
 
73
- type Locale = "zh-TW" | "en";
74
- declare const setLocale: (locale: Locale) => void;
75
- declare const getLocale: () => Locale;
2069
+ /**
2070
+ * @fileoverview Taiwan Business ID (統一編號) validator for Zod Kit
2071
+ *
2072
+ * Provides validation for Taiwan Business Identification Numbers (統一編號) with
2073
+ * support for both new (2023+) and legacy validation rules.
2074
+ *
2075
+ * @author Ong Hoe Yuan
2076
+ * @version 0.0.5
2077
+ */
2078
+
2079
+ /**
2080
+ * Type definition for business ID validation error messages
2081
+ *
2082
+ * @interface BusinessIdMessages
2083
+ * @property {string} [required] - Message when field is required but empty
2084
+ * @property {string} [invalid] - Message when business ID format or checksum is invalid
2085
+ */
2086
+ type BusinessIdMessages = {
2087
+ required?: string;
2088
+ invalid?: string;
2089
+ };
2090
+ /**
2091
+ * Configuration options for Taiwan business ID validation
2092
+ *
2093
+ * @template IsRequired - Whether the field is required (affects return type)
2094
+ *
2095
+ * @interface BusinessIdOptions
2096
+ * @property {IsRequired} [required=true] - Whether the field is required
2097
+ * @property {Function} [transform] - Custom transformation function for business ID
2098
+ * @property {string | null} [defaultValue] - Default value when input is empty
2099
+ * @property {Record<Locale, BusinessIdMessages>} [i18n] - Custom error messages for different locales
2100
+ */
2101
+ type BusinessIdOptions<IsRequired extends boolean = true> = {
2102
+ required?: IsRequired;
2103
+ transform?: (value: string) => string;
2104
+ defaultValue?: IsRequired extends true ? string : string | null;
2105
+ i18n?: Record<Locale, BusinessIdMessages>;
2106
+ };
2107
+ /**
2108
+ * Type alias for business ID validation schema based on required flag
2109
+ *
2110
+ * @template IsRequired - Whether the field is required
2111
+ * @typedef BusinessIdSchema
2112
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
2113
+ */
2114
+ type BusinessIdSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
2115
+ /**
2116
+ * Validates Taiwan Business Identification Number (統一編號)
2117
+ *
2118
+ * @param {string} value - The business ID to validate
2119
+ * @returns {boolean} True if the business ID is valid
2120
+ *
2121
+ * @description
2122
+ * Validates Taiwan Business ID using both new (2023+) and legacy validation rules.
2123
+ * The validation includes format checking (8 digits) and checksum verification.
2124
+ *
2125
+ * Validation rules:
2126
+ * 1. Must be exactly 8 digits
2127
+ * 2. Weighted sum calculation using coefficients [1,2,1,2,1,2,4] for first 7 digits
2128
+ * 3. New rules (2023+): Sum + 8th digit must be divisible by 5
2129
+ * 4. Legacy rules: Sum + 8th digit must be divisible by 10
2130
+ * 5. Special case: If 7th digit is 7, try alternative calculation with +1
2131
+ *
2132
+ * @example
2133
+ * ```typescript
2134
+ * validateTaiwanBusinessId("12345675") // true (if valid checksum)
2135
+ * validateTaiwanBusinessId("1234567") // false (not 8 digits)
2136
+ * validateTaiwanBusinessId("abcd1234") // false (not all digits)
2137
+ * ```
2138
+ */
2139
+ declare const validateTaiwanBusinessId: (value: string) => boolean;
2140
+ /**
2141
+ * Creates a Zod schema for Taiwan Business ID validation
2142
+ *
2143
+ * @template IsRequired - Whether the field is required (affects return type)
2144
+ * @param {BusinessIdOptions<IsRequired>} [options] - Configuration options for business ID validation
2145
+ * @returns {BusinessIdSchema<IsRequired>} Zod schema for business ID validation
2146
+ *
2147
+ * @description
2148
+ * Creates a comprehensive Taiwan Business ID validator that validates the format
2149
+ * and checksum according to Taiwan government specifications.
2150
+ *
2151
+ * Features:
2152
+ * - 8-digit format validation
2153
+ * - Checksum verification (supports both new 2023+ and legacy rules)
2154
+ * - Automatic trimming and preprocessing
2155
+ * - Custom transformation functions
2156
+ * - Comprehensive internationalization
2157
+ * - Optional field support
2158
+ *
2159
+ * @example
2160
+ * ```typescript
2161
+ * // Basic business ID validation
2162
+ * const basicSchema = businessId()
2163
+ * basicSchema.parse("12345675") // ✓ Valid (if checksum correct)
2164
+ * basicSchema.parse("1234567") // ✗ Invalid (not 8 digits)
2165
+ *
2166
+ * // Optional business ID
2167
+ * const optionalSchema = businessId({ required: false })
2168
+ * optionalSchema.parse("") // ✓ Valid (returns null)
2169
+ * optionalSchema.parse("12345675") // ✓ Valid (if checksum correct)
2170
+ *
2171
+ * // With custom transformation
2172
+ * const transformSchema = businessId({
2173
+ * transform: (value) => value.replace(/[^0-9]/g, '') // Remove non-digits
2174
+ * })
2175
+ * transformSchema.parse("1234-5675") // ✓ Valid (if checksum correct after cleaning)
2176
+ *
2177
+ * // With custom error messages
2178
+ * const customSchema = businessId({
2179
+ * i18n: {
2180
+ * en: { invalid: "Please enter a valid Taiwan Business ID" },
2181
+ * 'zh-TW': { invalid: "請輸入有效的統一編號" }
2182
+ * }
2183
+ * })
2184
+ * ```
2185
+ *
2186
+ * @throws {z.ZodError} When validation fails with specific error messages
2187
+ * @see {@link BusinessIdOptions} for all available configuration options
2188
+ * @see {@link validateTaiwanBusinessId} for validation logic details
2189
+ */
2190
+ declare function businessId<IsRequired extends boolean = true>(options?: BusinessIdOptions<IsRequired>): BusinessIdSchema<IsRequired>;
2191
+
2192
+ /**
2193
+ * @fileoverview Taiwan National ID (身分證/居留證) validator for Zod Kit
2194
+ *
2195
+ * Provides validation for Taiwan National ID cards (身分證) and
2196
+ * Resident Certificates (居留證) with support for both old and new formats.
2197
+ *
2198
+ * @author Ong Hoe Yuan
2199
+ * @version 0.0.5
2200
+ */
2201
+
2202
+ /**
2203
+ * Type definition for national ID validation error messages
2204
+ *
2205
+ * @interface NationalIdMessages
2206
+ * @property {string} [required] - Message when field is required but empty
2207
+ * @property {string} [invalid] - Message when national ID format or checksum is invalid
2208
+ */
2209
+ type NationalIdMessages = {
2210
+ required?: string;
2211
+ invalid?: string;
2212
+ };
2213
+ /**
2214
+ * Types of Taiwan national identification documents
2215
+ *
2216
+ * @typedef {"citizen" | "resident" | "both"} NationalIdType
2217
+ *
2218
+ * Available types:
2219
+ * - citizen: National ID card (身分證字號) for Taiwan citizens
2220
+ * - resident: Resident certificate (居留證號) for foreign residents
2221
+ * - both: Accept both citizen and resident IDs
2222
+ */
2223
+ type NationalIdType = "citizen" | "resident" | "both";
2224
+ /**
2225
+ * Configuration options for Taiwan national ID validation
2226
+ *
2227
+ * @template IsRequired - Whether the field is required (affects return type)
2228
+ *
2229
+ * @interface NationalIdOptions
2230
+ * @property {IsRequired} [required=true] - Whether the field is required
2231
+ * @property {NationalIdType} [type="both"] - Type of ID to accept
2232
+ * @property {boolean} [allowOldResident=true] - Whether to accept old-style resident certificates
2233
+ * @property {Function} [transform] - Custom transformation function for ID
2234
+ * @property {string | null} [defaultValue] - Default value when input is empty
2235
+ * @property {Record<Locale, NationalIdMessages>} [i18n] - Custom error messages for different locales
2236
+ */
2237
+ type NationalIdOptions<IsRequired extends boolean = true> = {
2238
+ required?: IsRequired;
2239
+ type?: NationalIdType;
2240
+ allowOldResident?: boolean;
2241
+ transform?: (value: string) => string;
2242
+ defaultValue?: IsRequired extends true ? string : string | null;
2243
+ i18n?: Record<Locale, NationalIdMessages>;
2244
+ };
2245
+ /**
2246
+ * Type alias for national ID validation schema based on required flag
2247
+ *
2248
+ * @template IsRequired - Whether the field is required
2249
+ * @typedef NationalIdSchema
2250
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
2251
+ */
2252
+ type NationalIdSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
2253
+ /**
2254
+ * Validates Taiwan citizen national ID card (身分證字號)
2255
+ *
2256
+ * @param {string} value - The citizen ID to validate
2257
+ * @returns {boolean} True if the citizen ID is valid
2258
+ *
2259
+ * @description
2260
+ * Validates Taiwan citizen ID format: 1 letter + 1 gender digit (1-2) + 8 digits
2261
+ * Uses checksum algorithm with city code conversion and weighted sum.
2262
+ *
2263
+ * Format: [A-Z][1-2]XXXXXXXX
2264
+ * - First letter: City/county code
2265
+ * - Second digit: Gender (1=male, 2=female)
2266
+ * - Last 8 digits: Serial number + checksum
2267
+ *
2268
+ * @example
2269
+ * ```typescript
2270
+ * validateCitizenId("A123456789") // true/false based on checksum
2271
+ * validateCitizenId("A323456789") // false (invalid gender digit)
2272
+ * ```
2273
+ */
2274
+ declare const validateCitizenId: (value: string) => boolean;
2275
+ /**
2276
+ * Validates old-style Taiwan resident certificate (舊式居留證號)
2277
+ *
2278
+ * @param {string} value - The old-style resident ID to validate
2279
+ * @returns {boolean} True if the old-style resident ID is valid
2280
+ *
2281
+ * @description
2282
+ * Validates old-style resident ID format: 1 letter + 1 gender letter + 8 digits
2283
+ * Uses checksum algorithm with city code and gender code conversion.
2284
+ *
2285
+ * Format: [A-Z][ABCD]XXXXXXXX
2286
+ * - First letter: City/county code
2287
+ * - Second letter: Gender code (A/C=male, B/D=female)
2288
+ * - Last 8 digits: Serial number + checksum
2289
+ *
2290
+ * @example
2291
+ * ```typescript
2292
+ * validateOldResidentId("AA12345678") // true/false based on checksum
2293
+ * validateOldResidentId("AE12345678") // false (invalid gender letter)
2294
+ * ```
2295
+ */
2296
+ declare const validateOldResidentId: (value: string) => boolean;
2297
+ /**
2298
+ * Validates new-style Taiwan resident certificate (新式居留證號)
2299
+ *
2300
+ * @param {string} value - The new-style resident ID to validate
2301
+ * @returns {boolean} True if the new-style resident ID is valid
2302
+ *
2303
+ * @description
2304
+ * Validates new-style resident ID format: 1 letter + 1 type digit + 8 digits
2305
+ * Uses the same checksum algorithm as citizen IDs.
2306
+ *
2307
+ * Format: [A-Z][89]XXXXXXXX
2308
+ * - First letter: City/county code
2309
+ * - Second digit: Type indicator (8 or 9)
2310
+ * - Last 8 digits: Serial number + checksum
2311
+ *
2312
+ * @example
2313
+ * ```typescript
2314
+ * validateNewResidentId("A812345678") // true/false based on checksum
2315
+ * validateNewResidentId("A712345678") // false (invalid type digit)
2316
+ * ```
2317
+ */
2318
+ declare const validateNewResidentId: (value: string) => boolean;
2319
+ /**
2320
+ * Main validation function for Taiwan national IDs
2321
+ *
2322
+ * @param {string} value - The national ID to validate
2323
+ * @param {NationalIdType} [type="both"] - Type of ID to accept
2324
+ * @param {boolean} [allowOldResident=true] - Whether to accept old-style resident certificates
2325
+ * @returns {boolean} True if the national ID is valid
2326
+ *
2327
+ * @description
2328
+ * Validates Taiwan national IDs based on the specified type and options.
2329
+ * Supports citizen IDs, resident certificates (both old and new styles).
2330
+ *
2331
+ * @example
2332
+ * ```typescript
2333
+ * validateTaiwanNationalId("A123456789", "citizen") // Citizen ID only
2334
+ * validateTaiwanNationalId("A812345678", "resident") // Resident ID only
2335
+ * validateTaiwanNationalId("A123456789", "both") // Accept any valid format
2336
+ * validateTaiwanNationalId("AA12345678", "both", false) // Reject old resident format
2337
+ * ```
2338
+ */
2339
+ declare const validateTaiwanNationalId: (value: string, type?: NationalIdType, allowOldResident?: boolean) => boolean;
2340
+ /**
2341
+ * Creates a Zod schema for Taiwan National ID validation
2342
+ *
2343
+ * @template IsRequired - Whether the field is required (affects return type)
2344
+ * @param {NationalIdOptions<IsRequired>} [options] - Configuration options for national ID validation
2345
+ * @returns {NationalIdSchema<IsRequired>} Zod schema for national ID validation
2346
+ *
2347
+ * @description
2348
+ * Creates a comprehensive Taiwan National ID validator that supports both
2349
+ * citizen IDs and resident certificates with configurable validation rules.
2350
+ *
2351
+ * Features:
2352
+ * - Citizen ID validation (身分證字號)
2353
+ * - Resident certificate validation (居留證號, old and new formats)
2354
+ * - Configurable ID type acceptance
2355
+ * - Automatic case conversion to uppercase
2356
+ * - Checksum verification
2357
+ * - Custom transformation functions
2358
+ * - Comprehensive internationalization
2359
+ * - Optional field support
2360
+ *
2361
+ * @example
2362
+ * ```typescript
2363
+ * // Accept any valid Taiwan ID
2364
+ * const anyIdSchema = nationalId()
2365
+ * anyIdSchema.parse("A123456789") // ✓ Valid citizen ID
2366
+ * anyIdSchema.parse("A812345678") // ✓ Valid new resident ID
2367
+ * anyIdSchema.parse("AA12345678") // ✓ Valid old resident ID
2368
+ *
2369
+ * // Citizen IDs only
2370
+ * const citizenSchema = nationalId({ type: "citizen" })
2371
+ * citizenSchema.parse("A123456789") // ✓ Valid
2372
+ * citizenSchema.parse("A812345678") // ✗ Invalid (resident ID)
2373
+ *
2374
+ * // Resident IDs only (new format only)
2375
+ * const residentSchema = nationalId({
2376
+ * type: "resident",
2377
+ * allowOldResident: false
2378
+ * })
2379
+ * residentSchema.parse("A812345678") // ✓ Valid
2380
+ * residentSchema.parse("AA12345678") // ✗ Invalid (old format)
2381
+ *
2382
+ * // Optional with custom transformation
2383
+ * const optionalSchema = nationalId({
2384
+ * required: false,
2385
+ * transform: (value) => value.replace(/[^A-Z0-9]/g, '') // Remove special chars
2386
+ * })
2387
+ *
2388
+ * // With custom error messages
2389
+ * const customSchema = nationalId({
2390
+ * i18n: {
2391
+ * en: { invalid: "Please enter a valid Taiwan National ID" },
2392
+ * 'zh-TW': { invalid: "請輸入有效的身分證或居留證號碼" }
2393
+ * }
2394
+ * })
2395
+ * ```
2396
+ *
2397
+ * @throws {z.ZodError} When validation fails with specific error messages
2398
+ * @see {@link NationalIdOptions} for all available configuration options
2399
+ * @see {@link NationalIdType} for supported ID types
2400
+ * @see {@link validateTaiwanNationalId} for validation logic details
2401
+ */
2402
+ declare function nationalId<IsRequired extends boolean = true>(options?: NationalIdOptions<IsRequired>): NationalIdSchema<IsRequired>;
2403
+
2404
+ /**
2405
+ * @fileoverview Taiwan Mobile Phone Number validator for Zod Kit
2406
+ *
2407
+ * Provides validation for Taiwan mobile phone numbers with support for
2408
+ * all Taiwan mobile network operators and whitelist functionality.
2409
+ *
2410
+ * @author Ong Hoe Yuan
2411
+ * @version 0.0.5
2412
+ */
2413
+
2414
+ /**
2415
+ * Type definition for mobile phone validation error messages
2416
+ *
2417
+ * @interface MobileMessages
2418
+ * @property {string} [required] - Message when field is required but empty
2419
+ * @property {string} [invalid] - Message when mobile number format is invalid
2420
+ * @property {string} [notInWhitelist] - Message when mobile number is not in whitelist
2421
+ */
2422
+ type MobileMessages = {
2423
+ required?: string;
2424
+ invalid?: string;
2425
+ notInWhitelist?: string;
2426
+ };
2427
+ /**
2428
+ * Configuration options for Taiwan mobile phone validation
2429
+ *
2430
+ * @template IsRequired - Whether the field is required (affects return type)
2431
+ *
2432
+ * @interface MobileOptions
2433
+ * @property {IsRequired} [required=true] - Whether the field is required
2434
+ * @property {string[]} [whitelist] - Array of specific mobile numbers that are always allowed
2435
+ * @property {Function} [transform] - Custom transformation function for mobile number
2436
+ * @property {string | null} [defaultValue] - Default value when input is empty
2437
+ * @property {Record<Locale, MobileMessages>} [i18n] - Custom error messages for different locales
2438
+ */
2439
+ type MobileOptions<IsRequired extends boolean = true> = {
2440
+ required?: IsRequired;
2441
+ whitelist?: string[];
2442
+ transform?: (value: string) => string;
2443
+ defaultValue?: IsRequired extends true ? string : string | null;
2444
+ i18n?: Record<Locale, MobileMessages>;
2445
+ };
2446
+ /**
2447
+ * Type alias for mobile phone validation schema based on required flag
2448
+ *
2449
+ * @template IsRequired - Whether the field is required
2450
+ * @typedef MobileSchema
2451
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
2452
+ */
2453
+ type MobileSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
2454
+ /**
2455
+ * Validates Taiwan mobile phone number format
2456
+ *
2457
+ * @param {string} value - The mobile phone number to validate
2458
+ * @returns {boolean} True if the mobile number is valid
2459
+ *
2460
+ * @description
2461
+ * Validates Taiwan mobile phone numbers according to the official numbering plan.
2462
+ * Taiwan mobile numbers use the format: 09X-XXXX-XXXX (10 digits total).
2463
+ *
2464
+ * Valid prefixes: 090, 091, 092, 093, 094, 095, 096, 097, 098, 099
2465
+ * - All major Taiwan mobile operators are covered
2466
+ * - Format: 09[0-9] followed by 7 additional digits
2467
+ *
2468
+ * @example
2469
+ * ```typescript
2470
+ * validateTaiwanMobile("0912345678") // true
2471
+ * validateTaiwanMobile("0987654321") // true
2472
+ * validateTaiwanMobile("0812345678") // false (invalid prefix)
2473
+ * validateTaiwanMobile("091234567") // false (too short)
2474
+ * ```
2475
+ */
2476
+ declare const validateTaiwanMobile: (value: string) => boolean;
2477
+ /**
2478
+ * Creates a Zod schema for Taiwan mobile phone number validation
2479
+ *
2480
+ * @template IsRequired - Whether the field is required (affects return type)
2481
+ * @param {MobileOptions<IsRequired>} [options] - Configuration options for mobile validation
2482
+ * @returns {MobileSchema<IsRequired>} Zod schema for mobile phone validation
2483
+ *
2484
+ * @description
2485
+ * Creates a comprehensive Taiwan mobile phone number validator with support for
2486
+ * all Taiwan mobile network operators and optional whitelist functionality.
2487
+ *
2488
+ * Features:
2489
+ * - Taiwan mobile number format validation (09X-XXXX-XXXX)
2490
+ * - Support for all Taiwan mobile operators (090-099 prefixes)
2491
+ * - Whitelist functionality for specific allowed numbers
2492
+ * - Automatic trimming and preprocessing
2493
+ * - Custom transformation functions
2494
+ * - Comprehensive internationalization
2495
+ * - Optional field support
2496
+ *
2497
+ * @example
2498
+ * ```typescript
2499
+ * // Basic mobile number validation
2500
+ * const basicSchema = mobile()
2501
+ * basicSchema.parse("0912345678") // ✓ Valid
2502
+ * basicSchema.parse("0987654321") // ✓ Valid
2503
+ * basicSchema.parse("0812345678") // ✗ Invalid (wrong prefix)
2504
+ *
2505
+ * // With whitelist (only specific numbers allowed)
2506
+ * const whitelistSchema = mobile({
2507
+ * whitelist: ["0912345678", "0987654321"]
2508
+ * })
2509
+ * whitelistSchema.parse("0912345678") // ✓ Valid (in whitelist)
2510
+ * whitelistSchema.parse("0911111111") // ✗ Invalid (not in whitelist)
2511
+ *
2512
+ * // Optional mobile number
2513
+ * const optionalSchema = mobile({ required: false })
2514
+ * optionalSchema.parse("") // ✓ Valid (returns null)
2515
+ * optionalSchema.parse("0912345678") // ✓ Valid
2516
+ *
2517
+ * // With custom transformation
2518
+ * const transformSchema = mobile({
2519
+ * transform: (value) => value.replace(/[^0-9]/g, '') // Remove non-digits
2520
+ * })
2521
+ * transformSchema.parse("091-234-5678") // ✓ Valid (formatted input)
2522
+ * transformSchema.parse("091 234 5678") // ✓ Valid (spaced input)
2523
+ *
2524
+ * // With custom error messages
2525
+ * const customSchema = mobile({
2526
+ * i18n: {
2527
+ * en: { invalid: "Please enter a valid Taiwan mobile number" },
2528
+ * 'zh-TW': { invalid: "請輸入有效的台灣手機號碼" }
2529
+ * }
2530
+ * })
2531
+ * ```
2532
+ *
2533
+ * @throws {z.ZodError} When validation fails with specific error messages
2534
+ * @see {@link MobileOptions} for all available configuration options
2535
+ * @see {@link validateTaiwanMobile} for validation logic details
2536
+ */
2537
+ declare function mobile<IsRequired extends boolean = true>(options?: MobileOptions<IsRequired>): MobileSchema<IsRequired>;
2538
+
2539
+ /**
2540
+ * @fileoverview Taiwan Postal Code validator for Zod Kit
2541
+ *
2542
+ * Provides comprehensive validation for Taiwan postal codes with support for
2543
+ * 3-digit, 5-digit (legacy), and 6-digit (current) formats based on official
2544
+ * Chunghwa Post specifications.
2545
+ *
2546
+ * @author Ong Hoe Yuan
2547
+ * @version 0.0.5
2548
+ */
2549
+
2550
+ /**
2551
+ * Type definition for postal code validation error messages
2552
+ *
2553
+ * @interface PostalCodeMessages
2554
+ * @property {string} [required] - Message when field is required but empty
2555
+ * @property {string} [invalid] - Message when postal code format is invalid
2556
+ * @property {string} [invalidFormat] - Message when format doesn't match expected pattern
2557
+ * @property {string} [invalidRange] - Message when postal code is outside valid range
2558
+ * @property {string} [legacy5DigitWarning] - Warning message for 5-digit legacy format
2559
+ * @property {string} [format3Only] - Message when only 3-digit format is allowed
2560
+ * @property {string} [format5Only] - Message when only 5-digit format is allowed
2561
+ * @property {string} [format6Only] - Message when only 6-digit format is allowed
2562
+ */
2563
+ type PostalCodeMessages = {
2564
+ required?: string;
2565
+ invalid?: string;
2566
+ invalidFormat?: string;
2567
+ invalidRange?: string;
2568
+ legacy5DigitWarning?: string;
2569
+ format3Only?: string;
2570
+ format5Only?: string;
2571
+ format6Only?: string;
2572
+ invalidSuffix?: string;
2573
+ deprecated5Digit?: string;
2574
+ };
2575
+ /**
2576
+ * Postal code format types supported in Taiwan
2577
+ *
2578
+ * @typedef {"3" | "5" | "6" | "3+5" | "3+6" | "5+6" | "all"} PostalCodeFormat
2579
+ *
2580
+ * Available formats:
2581
+ * - "3": 3-digit basic postal codes (100-982)
2582
+ * - "5": 5-digit postal codes (3+2 format, legacy)
2583
+ * - "6": 6-digit postal codes (3+3 format, current standard)
2584
+ * - "3+5": Accept both 3-digit and 5-digit formats
2585
+ * - "3+6": Accept both 3-digit and 6-digit formats (recommended)
2586
+ * - "5+6": Accept both 5-digit and 6-digit formats
2587
+ * - "all": Accept all formats (3, 5, and 6 digits)
2588
+ */
2589
+ type PostalCodeFormat = "3" | "5" | "6" | "3+5" | "3+6" | "5+6" | "all";
2590
+ /**
2591
+ * Configuration options for Taiwan postal code validation
2592
+ *
2593
+ * @template IsRequired - Whether the field is required (affects return type)
2594
+ *
2595
+ * @interface PostalCodeOptions
2596
+ * @property {IsRequired} [required=true] - Whether the field is required
2597
+ * @property {PostalCodeFormat} [format="3+6"] - Which postal code formats to accept
2598
+ * @property {boolean} [strictValidation=true] - Enable strict validation against known postal code ranges
2599
+ * @property {boolean} [allowDashes=true] - Whether to allow dashes in postal codes (e.g., "100-01" or "100-001")
2600
+ * @property {boolean} [warn5Digit=true] - Whether to show warning for 5-digit legacy format
2601
+ * @property {string[]} [allowedPrefixes] - Specific 3-digit prefixes to allow (if strictValidation is true)
2602
+ * @property {string[]} [blockedPrefixes] - Specific 3-digit prefixes to block
2603
+ * @property {Function} [transform] - Custom transformation function for postal codes
2604
+ * @property {string | null} [defaultValue] - Default value when input is empty
2605
+ * @property {Record<Locale, PostalCodeMessages>} [i18n] - Custom error messages for different locales
2606
+ */
2607
+ type PostalCodeOptions<IsRequired extends boolean = true> = {
2608
+ required?: IsRequired;
2609
+ format?: PostalCodeFormat;
2610
+ strictValidation?: boolean;
2611
+ allowDashes?: boolean;
2612
+ warn5Digit?: boolean;
2613
+ allowedPrefixes?: string[];
2614
+ blockedPrefixes?: string[];
2615
+ transform?: (value: string) => string;
2616
+ defaultValue?: IsRequired extends true ? string : string | null;
2617
+ i18n?: Record<Locale, PostalCodeMessages>;
2618
+ strictSuffixValidation?: boolean;
2619
+ deprecate5Digit?: boolean;
2620
+ };
2621
+ /**
2622
+ * Type alias for postal code validation schema based on required flag
2623
+ *
2624
+ * @template IsRequired - Whether the field is required
2625
+ * @typedef PostalCodeSchema
2626
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
2627
+ */
2628
+ type PostalCodeSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
2629
+ /**
2630
+ * Valid 3-digit postal code prefixes for Taiwan
2631
+ * Based on official Chunghwa Post data (2024)
2632
+ */
2633
+ declare const VALID_3_DIGIT_PREFIXES: string[];
2634
+ /**
2635
+ * Validates 3-digit Taiwan postal code
2636
+ *
2637
+ * @param {string} value - The 3-digit postal code to validate
2638
+ * @param {boolean} strictValidation - Whether to validate against known postal code list
2639
+ * @param {string[]} allowedPrefixes - Specific prefixes to allow (overrides strictValidation)
2640
+ * @param {string[]} blockedPrefixes - Specific prefixes to block
2641
+ * @returns {boolean} True if the postal code is valid
2642
+ */
2643
+ declare const validate3DigitPostalCode: (value: string, strictValidation?: boolean, allowedPrefixes?: string[], blockedPrefixes?: string[]) => boolean;
2644
+ /**
2645
+ * Validates 5-digit Taiwan postal code (legacy format)
2646
+ *
2647
+ * @param {string} value - The 5-digit postal code to validate
2648
+ * @param {boolean} strictValidation - Whether to validate the 3-digit prefix
2649
+ * @param {boolean} strictSuffixValidation - Whether to validate the 2-digit suffix
2650
+ * @param {string[]} allowedPrefixes - Specific prefixes to allow
2651
+ * @param {string[]} blockedPrefixes - Specific prefixes to block
2652
+ * @returns {boolean} True if the postal code is valid
2653
+ */
2654
+ declare const validate5DigitPostalCode: (value: string, strictValidation?: boolean, strictSuffixValidation?: boolean, allowedPrefixes?: string[], blockedPrefixes?: string[]) => boolean;
2655
+ /**
2656
+ * Validates 6-digit Taiwan postal code (current format)
2657
+ *
2658
+ * @param {string} value - The 6-digit postal code to validate
2659
+ * @param {boolean} strictValidation - Whether to validate the 3-digit prefix
2660
+ * @param {boolean} strictSuffixValidation - Whether to validate the 3-digit suffix
2661
+ * @param {string[]} allowedPrefixes - Specific prefixes to allow
2662
+ * @param {string[]} blockedPrefixes - Specific prefixes to block
2663
+ * @returns {boolean} True if the postal code is valid
2664
+ */
2665
+ declare const validate6DigitPostalCode: (value: string, strictValidation?: boolean, strictSuffixValidation?: boolean, allowedPrefixes?: string[], blockedPrefixes?: string[]) => boolean;
2666
+ /**
2667
+ * Main validation function for Taiwan postal codes
2668
+ *
2669
+ * @param {string} value - The postal code to validate
2670
+ * @param {PostalCodeFormat} format - Which formats to accept
2671
+ * @param {boolean} strictValidation - Whether to validate against known postal codes
2672
+ * @param {boolean} strictSuffixValidation - Whether to validate suffix ranges
2673
+ * @param {boolean} allowDashes - Whether dashes/spaces are allowed and should be removed
2674
+ * @param {string[]} allowedPrefixes - Specific prefixes to allow
2675
+ * @param {string[]} blockedPrefixes - Specific prefixes to block
2676
+ * @returns {boolean} True if the postal code is valid
2677
+ */
2678
+ declare const validateTaiwanPostalCode: (value: string, format?: PostalCodeFormat, strictValidation?: boolean, strictSuffixValidation?: boolean, allowDashes?: boolean, allowedPrefixes?: string[], blockedPrefixes?: string[]) => boolean;
2679
+ /**
2680
+ * Creates a Zod schema for Taiwan postal code validation
2681
+ *
2682
+ * @template IsRequired - Whether the field is required (affects return type)
2683
+ * @param {PostalCodeOptions<IsRequired>} [options] - Configuration options for postal code validation
2684
+ * @returns {PostalCodeSchema<IsRequired>} Zod schema for postal code validation
2685
+ *
2686
+ * @description
2687
+ * Creates a comprehensive Taiwan postal code validator that supports multiple formats
2688
+ * and provides extensive configuration options for different validation scenarios.
2689
+ *
2690
+ * Features:
2691
+ * - 3-digit, 5-digit, and 6-digit postal code format support
2692
+ * - Strict validation against official postal code ranges
2693
+ * - Legacy 5-digit format with optional warnings
2694
+ * - Custom prefix allowlist/blocklist support
2695
+ * - Dash and space handling in postal codes
2696
+ * - Automatic normalization and formatting
2697
+ * - Custom transformation functions
2698
+ * - Comprehensive internationalization
2699
+ * - Optional field support
2700
+ *
2701
+ * @example
2702
+ * ```typescript
2703
+ * // Accept 3-digit or 6-digit formats (recommended)
2704
+ * const modernSchema = postalCode()
2705
+ * modernSchema.parse("100") // ✓ Valid 3-digit
2706
+ * modernSchema.parse("100001") // ✓ Valid 6-digit
2707
+ * modernSchema.parse("10001") // ✗ Invalid (5-digit not allowed)
2708
+ *
2709
+ * // Accept all formats
2710
+ * const flexibleSchema = postalCode({ format: "all" })
2711
+ * flexibleSchema.parse("100") // ✓ Valid
2712
+ * flexibleSchema.parse("10001") // ✓ Valid
2713
+ * flexibleSchema.parse("100001") // ✓ Valid
2714
+ *
2715
+ * // Only 6-digit format (current standard)
2716
+ * const modernOnlySchema = postalCode({ format: "6" })
2717
+ * modernOnlySchema.parse("100001") // ✓ Valid
2718
+ * modernOnlySchema.parse("100") // ✗ Invalid
2719
+ *
2720
+ * // With dashes allowed
2721
+ * const dashSchema = postalCode({ allowDashes: true })
2722
+ * dashSchema.parse("100-001") // ✓ Valid (normalized to "100001")
2723
+ * dashSchema.parse("100-01") // ✓ Valid if 5-digit format allowed
2724
+ *
2725
+ * // Specific areas only
2726
+ * const taipeiSchema = postalCode({
2727
+ * allowedPrefixes: ["100", "103", "104", "105", "106"]
2728
+ * })
2729
+ * taipeiSchema.parse("100001") // ✓ Valid (Taipei area)
2730
+ * taipeiSchema.parse("200001") // ✗ Invalid (not in allowlist)
2731
+ *
2732
+ * // Block specific areas
2733
+ * const blockedSchema = postalCode({
2734
+ * blockedPrefixes: ["999"] // Block test codes
2735
+ * })
2736
+ *
2737
+ * // With warning for legacy format
2738
+ * const warnSchema = postalCode({
2739
+ * format: "all",
2740
+ * warn5Digit: true
2741
+ * })
2742
+ * // Will validate but may show warning for 5-digit codes
2743
+ *
2744
+ * // Optional with custom transformation
2745
+ * const optionalSchema = postalCode({
2746
+ * required: false,
2747
+ * transform: (value) => value.replace(/\D/g, '') // Remove non-digits
2748
+ * })
2749
+ *
2750
+ * // Strict suffix validation for real postal codes
2751
+ * const strictSchema = postalCode({
2752
+ * format: "6",
2753
+ * strictSuffixValidation: true // Validates suffix range 001-999
2754
+ * })
2755
+ * strictSchema.parse("100001") // ✓ Valid
2756
+ * strictSchema.parse("100000") // ✗ Invalid (suffix 000 not allowed)
2757
+ *
2758
+ * // Deprecate 5-digit codes entirely
2759
+ * const modern2024Schema = postalCode({
2760
+ * format: "all",
2761
+ * deprecate5Digit: true // Throws error for any 5-digit code
2762
+ * })
2763
+ * modern2024Schema.parse("100001") // ✓ Valid 6-digit
2764
+ * modern2024Schema.parse("10001") // ✗ Error: deprecated format
2765
+ * ```
2766
+ *
2767
+ * @throws {z.ZodError} When validation fails with specific error messages
2768
+ * @see {@link PostalCodeOptions} for all available configuration options
2769
+ * @see {@link PostalCodeFormat} for supported formats
2770
+ * @see {@link validateTaiwanPostalCode} for validation logic details
2771
+ */
2772
+ declare function postalCode<IsRequired extends boolean = true>(options?: PostalCodeOptions<IsRequired>): PostalCodeSchema<IsRequired>;
2773
+
2774
+ /**
2775
+ * @fileoverview Taiwan Landline Telephone Number validator for Zod Kit
2776
+ *
2777
+ * Provides validation for Taiwan landline telephone numbers according to the
2778
+ * official 2024 telecom numbering plan with comprehensive area code support.
2779
+ *
2780
+ * @author Ong Hoe Yuan
2781
+ * @version 0.0.5
2782
+ */
2783
+
2784
+ /**
2785
+ * Type definition for telephone validation error messages
2786
+ *
2787
+ * @interface TelMessages
2788
+ * @property {string} [required] - Message when field is required but empty
2789
+ * @property {string} [invalid] - Message when telephone number format is invalid
2790
+ * @property {string} [notInWhitelist] - Message when telephone number is not in whitelist
2791
+ */
2792
+ type TelMessages = {
2793
+ required?: string;
2794
+ invalid?: string;
2795
+ notInWhitelist?: string;
2796
+ };
2797
+ /**
2798
+ * Configuration options for Taiwan landline telephone validation
2799
+ *
2800
+ * @template IsRequired - Whether the field is required (affects return type)
2801
+ *
2802
+ * @interface TelOptions
2803
+ * @property {IsRequired} [required=true] - Whether the field is required
2804
+ * @property {string[]} [whitelist] - Array of specific telephone numbers that are always allowed
2805
+ * @property {Function} [transform] - Custom transformation function for telephone number
2806
+ * @property {string | null} [defaultValue] - Default value when input is empty
2807
+ * @property {Record<Locale, TelMessages>} [i18n] - Custom error messages for different locales
2808
+ */
2809
+ type TelOptions<IsRequired extends boolean = true> = {
2810
+ required?: IsRequired;
2811
+ whitelist?: string[];
2812
+ transform?: (value: string) => string;
2813
+ defaultValue?: IsRequired extends true ? string : string | null;
2814
+ i18n?: Record<Locale, TelMessages>;
2815
+ };
2816
+ /**
2817
+ * Type alias for telephone validation schema based on required flag
2818
+ *
2819
+ * @template IsRequired - Whether the field is required
2820
+ * @typedef TelSchema
2821
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
2822
+ */
2823
+ type TelSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
2824
+ /**
2825
+ * Validates Taiwan landline telephone number format (Official 2024 rules)
2826
+ *
2827
+ * @param {string} value - The telephone number to validate
2828
+ * @returns {boolean} True if the telephone number is valid
2829
+ *
2830
+ * @description
2831
+ * Validates Taiwan landline telephone numbers according to the official 2024
2832
+ * telecom numbering plan. Supports all Taiwan area codes and their specific
2833
+ * number patterns.
2834
+ *
2835
+ * Supported area codes and formats:
2836
+ * - 02: Taipei, New Taipei, Keelung - 8 digits (2&3&5~8+7D)
2837
+ * - 03: Taoyuan, Hsinchu, Yilan, Hualien - 7 digits
2838
+ * - 037: Miaoli - 6 digits (2~9+5D)
2839
+ * - 04: Taichung, Changhua - 7 digits
2840
+ * - 049: Nantou - 7 digits (2~9+6D)
2841
+ * - 05: Yunlin, Chiayi - 7 digits
2842
+ * - 06: Tainan - 7 digits
2843
+ * - 07: Kaohsiung - 7 digits (2~9+6D)
2844
+ * - 08: Pingtung - 7 digits (4&7&8+6D)
2845
+ * - 082: Kinmen - 6 digits (2~5&7~9+5D)
2846
+ * - 0826: Wuqiu - 5 digits (6+4D)
2847
+ * - 0836: Matsu - 5 digits (2~9+4D)
2848
+ * - 089: Taitung - 6 digits (2~9+5D)
2849
+ *
2850
+ * @example
2851
+ * ```typescript
2852
+ * validateTaiwanTel("0223456789") // true (Taipei area)
2853
+ * validateTaiwanTel("0312345678") // true (Taoyuan area)
2854
+ * validateTaiwanTel("037234567") // true (Miaoli area)
2855
+ * validateTaiwanTel("082234567") // true (Kinmen area)
2856
+ * validateTaiwanTel("02-2345-6789") // true (with separators)
2857
+ * validateTaiwanTel("0812345678") // false (invalid for 08 area)
2858
+ * ```
2859
+ */
2860
+ declare const validateTaiwanTel: (value: string) => boolean;
2861
+ /**
2862
+ * Creates a Zod schema for Taiwan landline telephone number validation
2863
+ *
2864
+ * @template IsRequired - Whether the field is required (affects return type)
2865
+ * @param {TelOptions<IsRequired>} [options] - Configuration options for telephone validation
2866
+ * @returns {TelSchema<IsRequired>} Zod schema for telephone number validation
2867
+ *
2868
+ * @description
2869
+ * Creates a comprehensive Taiwan landline telephone number validator with support for
2870
+ * all Taiwan area codes according to the official 2024 telecom numbering plan.
2871
+ *
2872
+ * Features:
2873
+ * - Complete Taiwan area code support (02, 03, 037, 04, 049, 05, 06, 07, 08, 082, 0826, 0836, 089)
2874
+ * - Automatic separator handling (hyphens and spaces)
2875
+ * - Area-specific number length and pattern validation
2876
+ * - Whitelist functionality for specific allowed numbers
2877
+ * - Automatic trimming and preprocessing
2878
+ * - Custom transformation functions
2879
+ * - Comprehensive internationalization
2880
+ * - Optional field support
2881
+ *
2882
+ * @example
2883
+ * ```typescript
2884
+ * // Basic telephone number validation
2885
+ * const basicSchema = tel()
2886
+ * basicSchema.parse("0223456789") // ✓ Valid (Taipei)
2887
+ * basicSchema.parse("0312345678") // ✓ Valid (Taoyuan)
2888
+ * basicSchema.parse("02-2345-6789") // ✓ Valid (with separators)
2889
+ * basicSchema.parse("0812345678") // ✗ Invalid (wrong format for 08)
2890
+ *
2891
+ * // With whitelist (only specific numbers allowed)
2892
+ * const whitelistSchema = tel({
2893
+ * whitelist: ["0223456789", "0312345678"]
2894
+ * })
2895
+ * whitelistSchema.parse("0223456789") // ✓ Valid (in whitelist)
2896
+ * whitelistSchema.parse("0287654321") // ✗ Invalid (not in whitelist)
2897
+ *
2898
+ * // Optional telephone number
2899
+ * const optionalSchema = tel({ required: false })
2900
+ * optionalSchema.parse("") // ✓ Valid (returns null)
2901
+ * optionalSchema.parse("0223456789") // ✓ Valid
2902
+ *
2903
+ * // With custom transformation (remove separators)
2904
+ * const transformSchema = tel({
2905
+ * transform: (value) => value.replace(/[^0-9]/g, '') // Keep only digits
2906
+ * })
2907
+ * transformSchema.parse("02-2345-6789") // ✓ Valid (separators removed)
2908
+ * transformSchema.parse("02 2345 6789") // ✓ Valid (spaces removed)
2909
+ *
2910
+ * // With custom error messages
2911
+ * const customSchema = tel({
2912
+ * i18n: {
2913
+ * en: { invalid: "Please enter a valid Taiwan landline number" },
2914
+ * 'zh-TW': { invalid: "請輸入有效的台灣市話號碼" }
2915
+ * }
2916
+ * })
2917
+ * ```
2918
+ *
2919
+ * @throws {z.ZodError} When validation fails with specific error messages
2920
+ * @see {@link TelOptions} for all available configuration options
2921
+ * @see {@link validateTaiwanTel} for validation logic details
2922
+ */
2923
+ declare function tel<IsRequired extends boolean = true>(options?: TelOptions<IsRequired>): TelSchema<IsRequired>;
2924
+
2925
+ /**
2926
+ * @fileoverview Taiwan Fax Number validator for Zod Kit
2927
+ *
2928
+ * Provides validation for Taiwan fax numbers according to the official 2024
2929
+ * telecom numbering plan. Uses the same format as landline telephone numbers.
2930
+ *
2931
+ * @author Ong Hoe Yuan
2932
+ * @version 0.0.5
2933
+ */
2934
+
2935
+ /**
2936
+ * Type definition for fax number validation error messages
2937
+ *
2938
+ * @interface FaxMessages
2939
+ * @property {string} [required] - Message when field is required but empty
2940
+ * @property {string} [invalid] - Message when fax number format is invalid
2941
+ * @property {string} [notInWhitelist] - Message when fax number is not in whitelist
2942
+ */
2943
+ type FaxMessages = {
2944
+ required?: string;
2945
+ invalid?: string;
2946
+ notInWhitelist?: string;
2947
+ };
2948
+ /**
2949
+ * Configuration options for Taiwan fax number validation
2950
+ *
2951
+ * @template IsRequired - Whether the field is required (affects return type)
2952
+ *
2953
+ * @interface FaxOptions
2954
+ * @property {IsRequired} [required=true] - Whether the field is required
2955
+ * @property {string[]} [whitelist] - Array of specific fax numbers that are always allowed
2956
+ * @property {Function} [transform] - Custom transformation function for fax number
2957
+ * @property {string | null} [defaultValue] - Default value when input is empty
2958
+ * @property {Record<Locale, FaxMessages>} [i18n] - Custom error messages for different locales
2959
+ */
2960
+ type FaxOptions<IsRequired extends boolean = true> = {
2961
+ required?: IsRequired;
2962
+ whitelist?: string[];
2963
+ transform?: (value: string) => string;
2964
+ defaultValue?: IsRequired extends true ? string : string | null;
2965
+ i18n?: Record<Locale, FaxMessages>;
2966
+ };
2967
+ /**
2968
+ * Type alias for fax number validation schema based on required flag
2969
+ *
2970
+ * @template IsRequired - Whether the field is required
2971
+ * @typedef FaxSchema
2972
+ * @description Returns ZodString if required, ZodNullable<ZodString> if optional
2973
+ */
2974
+ type FaxSchema<IsRequired extends boolean> = IsRequired extends true ? ZodString : ZodNullable<ZodString>;
2975
+ /**
2976
+ * Validates Taiwan fax number format (Official 2024 rules - same as landline)
2977
+ *
2978
+ * @param {string} value - The fax number to validate
2979
+ * @returns {boolean} True if the fax number is valid
2980
+ *
2981
+ * @description
2982
+ * Validates Taiwan fax numbers according to the official 2024 telecom numbering plan.
2983
+ * Fax numbers follow the same format as landline telephone numbers in Taiwan.
2984
+ *
2985
+ * Supported area codes and formats (same as landline):
2986
+ * - 02: Taipei, New Taipei, Keelung - 8 digits (2&3&5~8+7D)
2987
+ * - 03: Taoyuan, Hsinchu, Yilan, Hualien - 7 digits
2988
+ * - 037: Miaoli - 6 digits (2~9+5D)
2989
+ * - 04: Taichung, Changhua - 7 digits
2990
+ * - 049: Nantou - 7 digits (2~9+6D)
2991
+ * - 05: Yunlin, Chiayi - 7 digits
2992
+ * - 06: Tainan - 7 digits
2993
+ * - 07: Kaohsiung - 7 digits (2~9+6D)
2994
+ * - 08: Pingtung - 7 digits (4&7&8+6D)
2995
+ * - 082: Kinmen - 6 digits (2~5&7~9+5D)
2996
+ * - 0826: Wuqiu - 5 digits (6+4D)
2997
+ * - 0836: Matsu - 5 digits (2~9+4D)
2998
+ * - 089: Taitung - 6 digits (2~9+5D)
2999
+ *
3000
+ * @example
3001
+ * ```typescript
3002
+ * validateTaiwanFax("0223456789") // true (Taipei area)
3003
+ * validateTaiwanFax("0312345678") // true (Taoyuan area)
3004
+ * validateTaiwanFax("037234567") // true (Miaoli area)
3005
+ * validateTaiwanFax("02-2345-6789") // true (with separators)
3006
+ * validateTaiwanFax("0812345678") // false (invalid for 08 area)
3007
+ * ```
3008
+ */
3009
+ declare const validateTaiwanFax: (value: string) => boolean;
3010
+ /**
3011
+ * Creates a Zod schema for Taiwan fax number validation
3012
+ *
3013
+ * @template IsRequired - Whether the field is required (affects return type)
3014
+ * @param {FaxOptions<IsRequired>} [options] - Configuration options for fax validation
3015
+ * @returns {FaxSchema<IsRequired>} Zod schema for fax number validation
3016
+ *
3017
+ * @description
3018
+ * Creates a comprehensive Taiwan fax number validator with support for all Taiwan
3019
+ * area codes. Fax numbers follow the same format as landline telephone numbers.
3020
+ *
3021
+ * Features:
3022
+ * - Complete Taiwan area code support (same as landline)
3023
+ * - Automatic separator handling (hyphens and spaces)
3024
+ * - Area-specific number length and pattern validation
3025
+ * - Whitelist functionality for specific allowed numbers
3026
+ * - Automatic trimming and preprocessing
3027
+ * - Custom transformation functions
3028
+ * - Comprehensive internationalization
3029
+ * - Optional field support
3030
+ *
3031
+ * @example
3032
+ * ```typescript
3033
+ * // Basic fax number validation
3034
+ * const basicSchema = fax()
3035
+ * basicSchema.parse("0223456789") // ✓ Valid (Taipei)
3036
+ * basicSchema.parse("0312345678") // ✓ Valid (Taoyuan)
3037
+ * basicSchema.parse("02-2345-6789") // ✓ Valid (with separators)
3038
+ * basicSchema.parse("0812345678") // ✗ Invalid (wrong format for 08)
3039
+ *
3040
+ * // With whitelist (only specific numbers allowed)
3041
+ * const whitelistSchema = fax({
3042
+ * whitelist: ["0223456789", "0312345678"]
3043
+ * })
3044
+ * whitelistSchema.parse("0223456789") // ✓ Valid (in whitelist)
3045
+ * whitelistSchema.parse("0287654321") // ✗ Invalid (not in whitelist)
3046
+ *
3047
+ * // Optional fax number
3048
+ * const optionalSchema = fax({ required: false })
3049
+ * optionalSchema.parse("") // ✓ Valid (returns null)
3050
+ * optionalSchema.parse("0223456789") // ✓ Valid
3051
+ *
3052
+ * // With custom transformation
3053
+ * const transformSchema = fax({
3054
+ * transform: (value) => value.replace(/[^0-9]/g, '') // Keep only digits
3055
+ * })
3056
+ * transformSchema.parse("02-2345-6789") // ✓ Valid (separators removed)
3057
+ *
3058
+ * // With custom error messages
3059
+ * const customSchema = fax({
3060
+ * i18n: {
3061
+ * en: { invalid: "Please enter a valid Taiwan fax number" },
3062
+ * 'zh-TW': { invalid: "請輸入有效的台灣傳真號碼" }
3063
+ * }
3064
+ * })
3065
+ * ```
3066
+ *
3067
+ * @throws {z.ZodError} When validation fails with specific error messages
3068
+ * @see {@link FaxOptions} for all available configuration options
3069
+ * @see {@link validateTaiwanFax} for validation logic details
3070
+ */
3071
+ declare function fax<IsRequired extends boolean = true>(options?: FaxOptions<IsRequired>): FaxSchema<IsRequired>;
76
3072
 
77
- export { type BooleanOptions, type BooleanSchema, type EmailOptions, type EmailSchema, type IntegerOptions, type IntegerSchema, type Locale, type NumberOptions, type NumberSchema, type PasswordOptions, type PasswordSchema, type TextOptions, type TextSchema, type UrlOptions, type UrlSchema, boolean, email, getLocale, integer, number, password, setLocale, text, url };
3073
+ export { type BooleanMessages, type BooleanOptions, type BooleanSchema, type BusinessIdMessages, type BusinessIdOptions, type BusinessIdSchema, DATETIME_PATTERNS, type DateMessages, type DateOptions, type DateSchema, type DateTimeFormat, type DateTimeMessages, type DateTimeOptions, type DateTimeSchema, type EmailMessages, type EmailOptions, type EmailSchema, type FaxMessages, type FaxOptions, type FaxSchema, type FileMessages, type FileOptions, type FileSchema, ID_PATTERNS, type IdMessages, type IdOptions, type IdSchema, type IdType, type Locale, type MobileMessages, type MobileOptions, type MobileSchema, type NationalIdMessages, type NationalIdOptions, type NationalIdSchema, type NationalIdType, type NumberMessages, type NumberOptions, type NumberSchema, type PasswordMessages, type PasswordOptions, type PasswordSchema, type PasswordStrength, type PostalCodeFormat, type PostalCodeMessages, type PostalCodeOptions, type PostalCodeSchema, TIME_PATTERNS, type TelMessages, type TelOptions, type TelSchema, type TextMessages, type TextOptions, type TextSchema, type TimeFormat, type TimeMessages, type TimeOptions, type TimeSchema, type UrlMessages, type UrlOptions, type UrlSchema, VALID_3_DIGIT_PREFIXES, boolean, businessId, date, datetime, detectIdType, email, fax, file, getLocale, id, mobile, nationalId, normalizeDateTimeValue, normalizeTime, number, parseDateTimeValue, parseTimeToMinutes, password, postalCode, setLocale, tel, text, time, url, validate3DigitPostalCode, validate5DigitPostalCode, validate6DigitPostalCode, validateCitizenId, validateDateTimeFormat, validateIdType, validateNewResidentId, validateOldResidentId, validateTaiwanBusinessId, validateTaiwanFax, validateTaiwanMobile, validateTaiwanNationalId, validateTaiwanPostalCode, validateTaiwanTel, validateTimeFormat };