@hy_ong/zod-kit 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/.github/workflows/ci.yml +24 -0
  2. package/CLAUDE.md +64 -22
  3. package/dist/chunk-2SWEVDFZ.js +134 -0
  4. package/dist/chunk-32JI34CV.cjs +146 -0
  5. package/dist/chunk-42C5OHRK.js +71 -0
  6. package/dist/chunk-46VAH2BJ.js +160 -0
  7. package/dist/chunk-5JGTDL3Y.js +87 -0
  8. package/dist/chunk-5LEXCVLX.js +257 -0
  9. package/dist/chunk-6AAP4LPF.js +2606 -0
  10. package/dist/chunk-B4EZYZOK.cjs +215 -0
  11. package/dist/chunk-COYKBWTI.js +161 -0
  12. package/dist/chunk-DFJZ3NS2.cjs +151 -0
  13. package/dist/chunk-EDHT4LPO.js +118 -0
  14. package/dist/chunk-EGHL277K.cjs +165 -0
  15. package/dist/chunk-ERH4NIMU.cjs +69 -0
  16. package/dist/chunk-FM3EZ72O.js +165 -0
  17. package/dist/chunk-GJIRDBZJ.cjs +90 -0
  18. package/dist/chunk-H2XTEM4M.js +696 -0
  19. package/dist/chunk-HMSM6FFA.cjs +181 -0
  20. package/dist/chunk-HTEHINI7.cjs +177 -0
  21. package/dist/chunk-JOLSGZGN.cjs +696 -0
  22. package/dist/chunk-JXY7APBU.js +69 -0
  23. package/dist/chunk-K2UOY6TB.js +136 -0
  24. package/dist/chunk-KFOHKTFD.js +61 -0
  25. package/dist/chunk-L4HSIKTU.cjs +135 -0
  26. package/dist/chunk-LH7ZB4BK.js +124 -0
  27. package/dist/chunk-LL4ZWLGO.js +90 -0
  28. package/dist/chunk-M6MTP3NY.cjs +99 -0
  29. package/dist/chunk-MHJFYYGV.js +215 -0
  30. package/dist/chunk-MINMXGW3.js +135 -0
  31. package/dist/chunk-MM7IL2RG.js +181 -0
  32. package/dist/chunk-OPQJWHXN.cjs +301 -0
  33. package/dist/chunk-ORFHDJII.cjs +136 -0
  34. package/dist/chunk-ORVV4MCF.cjs +87 -0
  35. package/dist/chunk-QICQ6YEY.js +75 -0
  36. package/dist/chunk-RKUQREMW.js +127 -0
  37. package/dist/chunk-RO47DKQG.js +146 -0
  38. package/dist/chunk-RRPXIRTQ.cjs +257 -0
  39. package/dist/chunk-RYFG2GKM.cjs +118 -0
  40. package/dist/chunk-STNHTRG7.cjs +124 -0
  41. package/dist/chunk-TFGS34VD.cjs +71 -0
  42. package/dist/chunk-TQXDUMML.cjs +61 -0
  43. package/dist/chunk-UBK3VCVH.cjs +134 -0
  44. package/dist/chunk-UCOXAZJF.cjs +2606 -0
  45. package/dist/chunk-UQZKFAFX.js +130 -0
  46. package/dist/chunk-VB2KV2ZM.cjs +130 -0
  47. package/dist/chunk-WABKPFPK.js +151 -0
  48. package/dist/chunk-WDI4QJMQ.js +177 -0
  49. package/dist/chunk-YDH3L27K.cjs +127 -0
  50. package/dist/chunk-YIM3D2AD.js +99 -0
  51. package/dist/chunk-YPSEIDUR.cjs +160 -0
  52. package/dist/chunk-ZNJLWJX3.cjs +75 -0
  53. package/dist/chunk-ZTFCJCPO.cjs +161 -0
  54. package/dist/chunk-ZXUMK2RR.js +301 -0
  55. package/dist/common/boolean.cjs +7 -0
  56. package/dist/common/boolean.d.cts +119 -0
  57. package/dist/common/boolean.d.ts +119 -0
  58. package/dist/common/boolean.js +7 -0
  59. package/dist/common/color.cjs +9 -0
  60. package/dist/common/color.d.cts +26 -0
  61. package/dist/common/color.d.ts +26 -0
  62. package/dist/common/color.js +9 -0
  63. package/dist/common/coordinate.cjs +11 -0
  64. package/dist/common/coordinate.d.cts +23 -0
  65. package/dist/common/coordinate.d.ts +23 -0
  66. package/dist/common/coordinate.js +11 -0
  67. package/dist/common/credit-card.cjs +11 -0
  68. package/dist/common/credit-card.d.cts +22 -0
  69. package/dist/common/credit-card.d.ts +22 -0
  70. package/dist/common/credit-card.js +11 -0
  71. package/dist/common/date.cjs +7 -0
  72. package/dist/common/date.d.cts +174 -0
  73. package/dist/common/date.d.ts +174 -0
  74. package/dist/common/date.js +7 -0
  75. package/dist/common/datetime.cjs +15 -0
  76. package/dist/common/datetime.d.cts +301 -0
  77. package/dist/common/datetime.d.ts +301 -0
  78. package/dist/common/datetime.js +15 -0
  79. package/dist/common/email.cjs +7 -0
  80. package/dist/common/email.d.cts +149 -0
  81. package/dist/common/email.d.ts +149 -0
  82. package/dist/common/email.js +7 -0
  83. package/dist/common/file.cjs +7 -0
  84. package/dist/common/file.d.cts +178 -0
  85. package/dist/common/file.d.ts +178 -0
  86. package/dist/common/file.js +7 -0
  87. package/dist/common/id.cjs +13 -0
  88. package/dist/common/id.d.cts +288 -0
  89. package/dist/common/id.d.ts +288 -0
  90. package/dist/common/id.js +13 -0
  91. package/dist/common/ip.cjs +11 -0
  92. package/dist/common/ip.d.cts +25 -0
  93. package/dist/common/ip.d.ts +25 -0
  94. package/dist/common/ip.js +11 -0
  95. package/dist/common/number.cjs +7 -0
  96. package/dist/common/number.d.cts +167 -0
  97. package/dist/common/number.d.ts +167 -0
  98. package/dist/common/number.js +7 -0
  99. package/dist/common/password.cjs +7 -0
  100. package/dist/common/password.d.cts +192 -0
  101. package/dist/common/password.d.ts +192 -0
  102. package/dist/common/password.js +7 -0
  103. package/dist/common/text.cjs +7 -0
  104. package/dist/common/text.d.cts +156 -0
  105. package/dist/common/text.d.ts +156 -0
  106. package/dist/common/text.js +7 -0
  107. package/dist/common/time.cjs +15 -0
  108. package/dist/common/time.d.cts +268 -0
  109. package/dist/common/time.d.ts +268 -0
  110. package/dist/common/time.js +15 -0
  111. package/dist/common/url.cjs +7 -0
  112. package/dist/common/url.d.cts +196 -0
  113. package/dist/common/url.d.ts +196 -0
  114. package/dist/common/url.js +7 -0
  115. package/dist/config-CABSSvAp.d.cts +5 -0
  116. package/dist/config-CABSSvAp.d.ts +5 -0
  117. package/dist/index.cjs +180 -5255
  118. package/dist/index.d.cts +28 -3150
  119. package/dist/index.d.ts +28 -3150
  120. package/dist/index.js +135 -5131
  121. package/dist/taiwan/bank-account.cjs +11 -0
  122. package/dist/taiwan/bank-account.d.cts +22 -0
  123. package/dist/taiwan/bank-account.d.ts +22 -0
  124. package/dist/taiwan/bank-account.js +11 -0
  125. package/dist/taiwan/business-id.cjs +9 -0
  126. package/dist/taiwan/business-id.d.cts +133 -0
  127. package/dist/taiwan/business-id.d.ts +133 -0
  128. package/dist/taiwan/business-id.js +9 -0
  129. package/dist/taiwan/fax.cjs +9 -0
  130. package/dist/taiwan/fax.d.cts +157 -0
  131. package/dist/taiwan/fax.d.ts +157 -0
  132. package/dist/taiwan/fax.js +9 -0
  133. package/dist/taiwan/invoice.cjs +9 -0
  134. package/dist/taiwan/invoice.d.cts +17 -0
  135. package/dist/taiwan/invoice.d.ts +17 -0
  136. package/dist/taiwan/invoice.js +9 -0
  137. package/dist/taiwan/license-plate.cjs +9 -0
  138. package/dist/taiwan/license-plate.d.cts +19 -0
  139. package/dist/taiwan/license-plate.d.ts +19 -0
  140. package/dist/taiwan/license-plate.js +9 -0
  141. package/dist/taiwan/mobile.cjs +9 -0
  142. package/dist/taiwan/mobile.d.cts +146 -0
  143. package/dist/taiwan/mobile.d.ts +146 -0
  144. package/dist/taiwan/mobile.js +9 -0
  145. package/dist/taiwan/national-id.cjs +15 -0
  146. package/dist/taiwan/national-id.d.cts +214 -0
  147. package/dist/taiwan/national-id.d.ts +214 -0
  148. package/dist/taiwan/national-id.js +15 -0
  149. package/dist/taiwan/passport.cjs +9 -0
  150. package/dist/taiwan/passport.d.cts +19 -0
  151. package/dist/taiwan/passport.d.ts +19 -0
  152. package/dist/taiwan/passport.js +9 -0
  153. package/dist/taiwan/postal-code.cjs +17 -0
  154. package/dist/taiwan/postal-code.d.cts +237 -0
  155. package/dist/taiwan/postal-code.d.ts +237 -0
  156. package/dist/taiwan/postal-code.js +17 -0
  157. package/dist/taiwan/tel.cjs +9 -0
  158. package/dist/taiwan/tel.d.cts +162 -0
  159. package/dist/taiwan/tel.d.ts +162 -0
  160. package/dist/taiwan/tel.js +9 -0
  161. package/package.json +132 -6
  162. package/src/i18n/locales/en-GB.json +51 -0
  163. package/src/i18n/locales/en-US.json +52 -1
  164. package/src/i18n/locales/id-ID.json +51 -0
  165. package/src/i18n/locales/ja-JP.json +51 -0
  166. package/src/i18n/locales/ko-KR.json +51 -0
  167. package/src/i18n/locales/ms-MY.json +51 -0
  168. package/src/i18n/locales/th-TH.json +51 -0
  169. package/src/i18n/locales/vi-VN.json +51 -0
  170. package/src/i18n/locales/zh-CN.json +51 -0
  171. package/src/i18n/locales/zh-TW.json +51 -0
  172. package/src/index.ts +10 -2
  173. package/src/validators/common/color.ts +192 -0
  174. package/src/validators/common/coordinate.ts +159 -0
  175. package/src/validators/common/credit-card.ts +134 -0
  176. package/src/validators/common/id.ts +45 -3
  177. package/src/validators/common/ip.ts +210 -0
  178. package/src/validators/taiwan/bank-account.ts +176 -0
  179. package/src/validators/taiwan/invoice.ts +84 -0
  180. package/src/validators/taiwan/license-plate.ts +110 -0
  181. package/src/validators/taiwan/passport.ts +103 -0
  182. package/tests/common/color.test.ts +587 -0
  183. package/tests/common/coordinate.test.ts +345 -0
  184. package/tests/common/credit-card.test.ts +378 -0
  185. package/tests/common/id.test.ts +68 -3
  186. package/tests/common/ip.test.ts +419 -0
  187. package/tests/taiwan/bank-account.test.ts +286 -0
  188. package/tests/taiwan/invoice.test.ts +227 -0
  189. package/tests/taiwan/license-plate.test.ts +280 -0
  190. package/tests/taiwan/passport.test.ts +277 -0
  191. package/tsup.config.ts +36 -0
@@ -0,0 +1,696 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+ var _chunkUCOXAZJFcjs = require('./chunk-UCOXAZJF.cjs');
5
+
6
+ // src/validators/taiwan/postal-code.ts
7
+ var _zod = require('zod');
8
+ var VALID_3_DIGIT_PREFIXES = [
9
+ // Taipei City (台北市) - 100-116
10
+ "100",
11
+ "103",
12
+ "104",
13
+ "105",
14
+ "106",
15
+ "108",
16
+ "110",
17
+ "111",
18
+ "112",
19
+ "114",
20
+ "115",
21
+ "116",
22
+ // New Taipei City (新北市) - 200-253
23
+ "200",
24
+ "201",
25
+ "202",
26
+ "203",
27
+ "204",
28
+ "205",
29
+ "206",
30
+ "207",
31
+ "208",
32
+ "220",
33
+ "221",
34
+ "222",
35
+ "223",
36
+ "224",
37
+ "226",
38
+ "227",
39
+ "228",
40
+ "231",
41
+ "232",
42
+ "233",
43
+ "234",
44
+ "235",
45
+ "236",
46
+ "237",
47
+ "238",
48
+ "239",
49
+ "241",
50
+ "242",
51
+ "243",
52
+ "244",
53
+ "247",
54
+ "248",
55
+ "249",
56
+ "251",
57
+ "252",
58
+ "253",
59
+ // Keelung City (基隆市) - 200-206
60
+ "200",
61
+ "201",
62
+ "202",
63
+ "203",
64
+ "204",
65
+ "205",
66
+ "206",
67
+ // Taoyuan City (桃園市) - 300-338
68
+ "300",
69
+ "302",
70
+ "303",
71
+ "304",
72
+ "305",
73
+ "306",
74
+ "307",
75
+ "308",
76
+ "310",
77
+ "311",
78
+ "312",
79
+ "313",
80
+ "314",
81
+ "315",
82
+ "316",
83
+ "317",
84
+ "318",
85
+ "320",
86
+ "324",
87
+ "325",
88
+ "326",
89
+ "327",
90
+ "328",
91
+ "330",
92
+ "333",
93
+ "334",
94
+ "335",
95
+ "336",
96
+ "337",
97
+ "338",
98
+ // Hsinchu County (新竹縣) - 300-315
99
+ "300",
100
+ "302",
101
+ "303",
102
+ "304",
103
+ "305",
104
+ "306",
105
+ "307",
106
+ "308",
107
+ "310",
108
+ "311",
109
+ "312",
110
+ "313",
111
+ "314",
112
+ "315",
113
+ // Hsinchu City (新竹市) - 300
114
+ "300",
115
+ // Miaoli County (苗栗縣) - 350-369
116
+ "350",
117
+ "351",
118
+ "352",
119
+ "353",
120
+ "354",
121
+ "356",
122
+ "357",
123
+ "358",
124
+ "360",
125
+ "361",
126
+ "362",
127
+ "363",
128
+ "364",
129
+ "365",
130
+ "366",
131
+ "367",
132
+ "368",
133
+ "369",
134
+ // Taichung City (台中市) - 400-439
135
+ "400",
136
+ "401",
137
+ "402",
138
+ "403",
139
+ "404",
140
+ "406",
141
+ "407",
142
+ "408",
143
+ "411",
144
+ "412",
145
+ "413",
146
+ "414",
147
+ "420",
148
+ "421",
149
+ "422",
150
+ "423",
151
+ "424",
152
+ "426",
153
+ "427",
154
+ "428",
155
+ "429",
156
+ "432",
157
+ "433",
158
+ "434",
159
+ "435",
160
+ "436",
161
+ "437",
162
+ "438",
163
+ "439",
164
+ // Changhua County (彰化縣) - 500-530
165
+ "500",
166
+ "502",
167
+ "503",
168
+ "504",
169
+ "505",
170
+ "506",
171
+ "507",
172
+ "508",
173
+ "509",
174
+ "510",
175
+ "511",
176
+ "512",
177
+ "513",
178
+ "514",
179
+ "515",
180
+ "516",
181
+ "520",
182
+ "521",
183
+ "522",
184
+ "523",
185
+ "524",
186
+ "525",
187
+ "526",
188
+ "527",
189
+ "528",
190
+ "530",
191
+ // Nantou County (南投縣) - 540-558
192
+ "540",
193
+ "541",
194
+ "542",
195
+ "544",
196
+ "545",
197
+ "546",
198
+ "551",
199
+ "552",
200
+ "553",
201
+ "555",
202
+ "556",
203
+ "557",
204
+ "558",
205
+ // Yunlin County (雲林縣) - 630-655
206
+ "630",
207
+ "631",
208
+ "632",
209
+ "633",
210
+ "634",
211
+ "635",
212
+ "636",
213
+ "637",
214
+ "638",
215
+ "640",
216
+ "643",
217
+ "646",
218
+ "647",
219
+ "648",
220
+ "649",
221
+ "651",
222
+ "652",
223
+ "653",
224
+ "654",
225
+ "655",
226
+ // Chiayi County (嘉義縣) - 600-625
227
+ "600",
228
+ "602",
229
+ "603",
230
+ "604",
231
+ "605",
232
+ "606",
233
+ "607",
234
+ "608",
235
+ "611",
236
+ "612",
237
+ "613",
238
+ "614",
239
+ "615",
240
+ "616",
241
+ "621",
242
+ "622",
243
+ "623",
244
+ "624",
245
+ "625",
246
+ // Chiayi City (嘉義市) - 600
247
+ "600",
248
+ // Tainan City (台南市) - 700-745
249
+ "700",
250
+ "701",
251
+ "702",
252
+ "704",
253
+ "708",
254
+ "709",
255
+ "710",
256
+ "711",
257
+ "712",
258
+ "713",
259
+ "714",
260
+ "715",
261
+ "716",
262
+ "717",
263
+ "718",
264
+ "719",
265
+ "720",
266
+ "721",
267
+ "722",
268
+ "723",
269
+ "724",
270
+ "725",
271
+ "726",
272
+ "727",
273
+ "730",
274
+ "731",
275
+ "732",
276
+ "733",
277
+ "734",
278
+ "735",
279
+ "736",
280
+ "737",
281
+ "741",
282
+ "742",
283
+ "743",
284
+ "744",
285
+ "745",
286
+ // Kaohsiung City (高雄市) - 800-852
287
+ "800",
288
+ "801",
289
+ "802",
290
+ "803",
291
+ "804",
292
+ "805",
293
+ "806",
294
+ "807",
295
+ "811",
296
+ "812",
297
+ "813",
298
+ "814",
299
+ "815",
300
+ "820",
301
+ "821",
302
+ "822",
303
+ "823",
304
+ "824",
305
+ "825",
306
+ "826",
307
+ "827",
308
+ "828",
309
+ "829",
310
+ "830",
311
+ "831",
312
+ "832",
313
+ "833",
314
+ "840",
315
+ "842",
316
+ "843",
317
+ "844",
318
+ "845",
319
+ "846",
320
+ "847",
321
+ "848",
322
+ "849",
323
+ "851",
324
+ "852",
325
+ // Pingtung County (屏東縣) - 900-947
326
+ "900",
327
+ "901",
328
+ "902",
329
+ "903",
330
+ "904",
331
+ "905",
332
+ "906",
333
+ "907",
334
+ "908",
335
+ "909",
336
+ "911",
337
+ "912",
338
+ "913",
339
+ "920",
340
+ "921",
341
+ "922",
342
+ "923",
343
+ "924",
344
+ "925",
345
+ "926",
346
+ "927",
347
+ "928",
348
+ "929",
349
+ "931",
350
+ "932",
351
+ "940",
352
+ "941",
353
+ "942",
354
+ "943",
355
+ "944",
356
+ "945",
357
+ "946",
358
+ "947",
359
+ // Yilan County (宜蘭縣) - 260-269
360
+ "260",
361
+ "261",
362
+ "262",
363
+ "263",
364
+ "264",
365
+ "265",
366
+ "266",
367
+ "267",
368
+ "268",
369
+ "269",
370
+ // Hualien County (花蓮縣) - 970-983
371
+ "970",
372
+ "971",
373
+ "972",
374
+ "973",
375
+ "974",
376
+ "975",
377
+ "976",
378
+ "977",
379
+ "978",
380
+ "979",
381
+ "981",
382
+ "982",
383
+ "983",
384
+ // Taitung County (台東縣) - 950-966
385
+ "950",
386
+ "951",
387
+ "952",
388
+ "953",
389
+ "954",
390
+ "955",
391
+ "956",
392
+ "957",
393
+ "958",
394
+ "959",
395
+ "961",
396
+ "962",
397
+ "963",
398
+ "964",
399
+ "965",
400
+ "966",
401
+ // Penghu County (澎湖縣) - 880-885
402
+ "880",
403
+ "881",
404
+ "882",
405
+ "883",
406
+ "884",
407
+ "885",
408
+ // Kinmen County (金門縣) - 890-896
409
+ "890",
410
+ "891",
411
+ "892",
412
+ "893",
413
+ "894",
414
+ "895",
415
+ "896",
416
+ // Lienchiang County (連江縣/馬祖) - 209-212
417
+ "209",
418
+ "210",
419
+ "211",
420
+ "212"
421
+ ];
422
+ var POSTAL_CODE_RANGES = {
423
+ // Major cities with extensive postal networks
424
+ "100": { range5: [1, 99], range6: [1, 999] },
425
+ // Taipei City - Zhongzheng
426
+ "103": { range5: [1, 99], range6: [1, 999] },
427
+ // Taipei City - Datong
428
+ "104": { range5: [1, 99], range6: [1, 999] },
429
+ // Taipei City - Zhongshan
430
+ "105": { range5: [1, 99], range6: [1, 999] },
431
+ // Taipei City - Songshan
432
+ "106": { range5: [1, 99], range6: [1, 999] },
433
+ // Taipei City - Da'an
434
+ "108": { range5: [1, 99], range6: [1, 999] },
435
+ // Taipei City - Wanhua
436
+ "110": { range5: [1, 99], range6: [1, 999] },
437
+ // Taipei City - Xinyi
438
+ "111": { range5: [1, 99], range6: [1, 999] },
439
+ // Taipei City - Shilin
440
+ "112": { range5: [1, 99], range6: [1, 999] },
441
+ // Taipei City - Beitou
442
+ "114": { range5: [1, 99], range6: [1, 999] },
443
+ // Taipei City - Neihu
444
+ "115": { range5: [1, 99], range6: [1, 999] },
445
+ // Taipei City - Nangang
446
+ "116": { range5: [1, 99], range6: [1, 999] },
447
+ // Taipei City - Wenshan
448
+ // New Taipei City major areas
449
+ "220": { range5: [1, 99], range6: [1, 999] },
450
+ // Banqiao
451
+ "221": { range5: [1, 99], range6: [1, 999] },
452
+ // Xizhi
453
+ "222": { range5: [1, 99], range6: [1, 999] },
454
+ // Shenkeng
455
+ "223": { range5: [1, 99], range6: [1, 999] },
456
+ // Shiding
457
+ "224": { range5: [1, 99], range6: [1, 999] },
458
+ // Ruifang
459
+ // Taoyuan City
460
+ "320": { range5: [1, 99], range6: [1, 999] },
461
+ // Zhongli
462
+ "324": { range5: [1, 99], range6: [1, 999] },
463
+ // Pingzhen
464
+ "330": { range5: [1, 99], range6: [1, 999] },
465
+ // Taoyuan
466
+ // Taichung City
467
+ "400": { range5: [1, 99], range6: [1, 999] },
468
+ // Central District
469
+ "401": { range5: [1, 99], range6: [1, 999] },
470
+ // East District
471
+ "402": { range5: [1, 99], range6: [1, 999] },
472
+ // South District
473
+ "403": { range5: [1, 99], range6: [1, 999] },
474
+ // West District
475
+ "404": { range5: [1, 99], range6: [1, 999] },
476
+ // North District
477
+ // Tainan City
478
+ "700": { range5: [1, 99], range6: [1, 999] },
479
+ // Central District
480
+ "701": { range5: [1, 99], range6: [1, 999] },
481
+ // East District
482
+ "702": { range5: [1, 99], range6: [1, 999] },
483
+ // South District
484
+ // Kaohsiung City
485
+ "800": { range5: [1, 99], range6: [1, 999] },
486
+ // Xinxing
487
+ "801": { range5: [1, 99], range6: [1, 999] },
488
+ // Qianjin
489
+ "802": { range5: [1, 99], range6: [1, 999] },
490
+ // Lingya
491
+ "803": { range5: [1, 99], range6: [1, 999] },
492
+ // Yancheng
493
+ // Smaller areas with more limited ranges
494
+ "880": { range5: [1, 50], range6: [1, 500] },
495
+ // Penghu (smaller population)
496
+ "890": { range5: [1, 30], range6: [1, 300] },
497
+ // Kinmen (smaller population)
498
+ "209": { range5: [1, 20], range6: [1, 200] }
499
+ // Lienchiang/Matsu (smallest population)
500
+ };
501
+ var getPostalCodeRanges = (prefix) => {
502
+ return POSTAL_CODE_RANGES[prefix] || {
503
+ range5: [1, 99],
504
+ // Default range for 5-digit
505
+ range6: [1, 999]
506
+ // Default range for 6-digit
507
+ };
508
+ };
509
+ var validate3DigitPostalCode = (value, strictValidation = true, allowedPrefixes, blockedPrefixes) => {
510
+ if (!/^\d{3}$/.test(value)) {
511
+ return false;
512
+ }
513
+ if (blockedPrefixes && blockedPrefixes.includes(value)) {
514
+ return false;
515
+ }
516
+ if (allowedPrefixes) {
517
+ return allowedPrefixes.includes(value);
518
+ }
519
+ if (strictValidation) {
520
+ return VALID_3_DIGIT_PREFIXES.includes(value);
521
+ }
522
+ const num = parseInt(value, 10);
523
+ return num >= 100 && num <= 999;
524
+ };
525
+ var validate5DigitPostalCode = (value, strictValidation = true, strictSuffixValidation = false, allowedPrefixes, blockedPrefixes) => {
526
+ if (!/^\d{5}$/.test(value)) {
527
+ return false;
528
+ }
529
+ const prefix = value.substring(0, 3);
530
+ const suffix = value.substring(3, 5);
531
+ if (!validate3DigitPostalCode(prefix, strictValidation, allowedPrefixes, blockedPrefixes)) {
532
+ return false;
533
+ }
534
+ if (strictSuffixValidation) {
535
+ const suffixNum = parseInt(suffix, 10);
536
+ const ranges = getPostalCodeRanges(prefix);
537
+ if (suffixNum < ranges.range5[0] || suffixNum > ranges.range5[1]) {
538
+ return false;
539
+ }
540
+ }
541
+ return true;
542
+ };
543
+ var validate6DigitPostalCode = (value, strictValidation = true, strictSuffixValidation = false, allowedPrefixes, blockedPrefixes) => {
544
+ if (!/^\d{6}$/.test(value)) {
545
+ return false;
546
+ }
547
+ const prefix = value.substring(0, 3);
548
+ const suffix = value.substring(3, 6);
549
+ if (!validate3DigitPostalCode(prefix, strictValidation, allowedPrefixes, blockedPrefixes)) {
550
+ return false;
551
+ }
552
+ if (strictSuffixValidation) {
553
+ const suffixNum = parseInt(suffix, 10);
554
+ const ranges = getPostalCodeRanges(prefix);
555
+ if (suffixNum < ranges.range6[0] || suffixNum > ranges.range6[1]) {
556
+ return false;
557
+ }
558
+ }
559
+ return true;
560
+ };
561
+ var validateTaiwanPostalCode = (value, format = "3+6", strictValidation = true, strictSuffixValidation = false, allowDashes = true, allowedPrefixes, blockedPrefixes) => {
562
+ if (!value || typeof value !== "string") {
563
+ return false;
564
+ }
565
+ const cleanValue = allowDashes ? value.replace(/[-\s]/g, "") : value;
566
+ if (!allowDashes && /[-\s]/.test(value)) {
567
+ return false;
568
+ }
569
+ switch (format) {
570
+ case "3":
571
+ return cleanValue.length === 3 && validate3DigitPostalCode(cleanValue, strictValidation, allowedPrefixes, blockedPrefixes);
572
+ case "5":
573
+ return cleanValue.length === 5 && validate5DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes);
574
+ case "6":
575
+ return cleanValue.length === 6 && validate6DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes);
576
+ case "3+5":
577
+ return cleanValue.length === 3 && validate3DigitPostalCode(cleanValue, strictValidation, allowedPrefixes, blockedPrefixes) || cleanValue.length === 5 && validate5DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes);
578
+ case "3+6":
579
+ return cleanValue.length === 3 && validate3DigitPostalCode(cleanValue, strictValidation, allowedPrefixes, blockedPrefixes) || cleanValue.length === 6 && validate6DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes);
580
+ case "5+6":
581
+ return cleanValue.length === 5 && validate5DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes) || cleanValue.length === 6 && validate6DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes);
582
+ case "all":
583
+ return cleanValue.length === 3 && validate3DigitPostalCode(cleanValue, strictValidation, allowedPrefixes, blockedPrefixes) || cleanValue.length === 5 && validate5DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes) || cleanValue.length === 6 && validate6DigitPostalCode(cleanValue, strictValidation, strictSuffixValidation, allowedPrefixes, blockedPrefixes);
584
+ default:
585
+ return false;
586
+ }
587
+ };
588
+ function twPostalCode(required, options) {
589
+ const {
590
+ format = "3+6",
591
+ strictValidation = true,
592
+ allowDashes = true,
593
+ warn5Digit = true,
594
+ allowedPrefixes,
595
+ blockedPrefixes,
596
+ transform,
597
+ defaultValue,
598
+ i18n,
599
+ strictSuffixValidation = false,
600
+ deprecate5Digit = false
601
+ } = _nullishCoalesce(options, () => ( {}));
602
+ const isRequired = _nullishCoalesce(required, () => ( false));
603
+ const actualDefaultValue = _nullishCoalesce(defaultValue, () => ( (isRequired ? "" : null)));
604
+ const getMessage = (key, params) => {
605
+ if (i18n) {
606
+ const currentLocale = _chunkUCOXAZJFcjs.getLocale.call(void 0, );
607
+ const customMessages = i18n[currentLocale];
608
+ if (customMessages && customMessages[key]) {
609
+ const template = customMessages[key];
610
+ return template.replace(/\$\{(\w+)}/g, (_, k) => _nullishCoalesce(_optionalChain([params, 'optionalAccess', _2 => _2[k]]), () => ( "")));
611
+ }
612
+ }
613
+ return _chunkUCOXAZJFcjs.t.call(void 0, `taiwan.postalCode.${key}`, params);
614
+ };
615
+ const preprocessFn = (val) => {
616
+ if (val === "" || val === null || val === void 0) {
617
+ return actualDefaultValue;
618
+ }
619
+ let processed = String(val).trim();
620
+ if (allowDashes) {
621
+ processed = processed.replace(/[-\s]/g, "");
622
+ }
623
+ if (processed === "" && !required) {
624
+ return null;
625
+ }
626
+ if (transform) {
627
+ processed = transform(processed);
628
+ }
629
+ return processed;
630
+ };
631
+ const baseSchema = isRequired ? _zod.z.preprocess(preprocessFn, _zod.z.string()) : _zod.z.preprocess(preprocessFn, _zod.z.string().nullable());
632
+ const schema = baseSchema.superRefine((val, ctx) => {
633
+ if (val === null) return;
634
+ if (isRequired && (val === "" || val === "null" || val === "undefined")) {
635
+ ctx.addIssue({ code: "custom", message: getMessage("required") });
636
+ return;
637
+ }
638
+ if (val === null) return;
639
+ if (!isRequired && val === "") return;
640
+ const cleanValue = val.replace(/[-\s]/g, "");
641
+ if (format === "3" && cleanValue.length !== 3) {
642
+ ctx.addIssue({ code: "custom", message: getMessage("format3Only") });
643
+ return;
644
+ }
645
+ if (format === "5" && cleanValue.length !== 5) {
646
+ ctx.addIssue({ code: "custom", message: getMessage("format5Only") });
647
+ return;
648
+ }
649
+ if (format === "6" && cleanValue.length !== 6) {
650
+ ctx.addIssue({ code: "custom", message: getMessage("format6Only") });
651
+ return;
652
+ }
653
+ if (deprecate5Digit && cleanValue.length === 5) {
654
+ ctx.addIssue({ code: "custom", message: getMessage("deprecated5Digit") });
655
+ return;
656
+ }
657
+ if (strictSuffixValidation) {
658
+ if (cleanValue.length === 5) {
659
+ const prefix = cleanValue.substring(0, 3);
660
+ const suffix = cleanValue.substring(3, 5);
661
+ const suffixNum = parseInt(suffix, 10);
662
+ const ranges = getPostalCodeRanges(prefix);
663
+ if (suffixNum < ranges.range5[0] || suffixNum > ranges.range5[1]) {
664
+ ctx.addIssue({ code: "custom", message: getMessage("invalidSuffix") });
665
+ return;
666
+ }
667
+ } else if (cleanValue.length === 6) {
668
+ const prefix = cleanValue.substring(0, 3);
669
+ const suffix = cleanValue.substring(3, 6);
670
+ const suffixNum = parseInt(suffix, 10);
671
+ const ranges = getPostalCodeRanges(prefix);
672
+ if (suffixNum < ranges.range6[0] || suffixNum > ranges.range6[1]) {
673
+ ctx.addIssue({ code: "custom", message: getMessage("invalidSuffix") });
674
+ return;
675
+ }
676
+ }
677
+ }
678
+ if (!validateTaiwanPostalCode(val, format, strictValidation, strictSuffixValidation, allowDashes, allowedPrefixes, blockedPrefixes)) {
679
+ ctx.addIssue({ code: "custom", message: getMessage("invalid") });
680
+ return;
681
+ }
682
+ if (warn5Digit && cleanValue.length === 5 && format !== "5" && !deprecate5Digit) {
683
+ console.warn(getMessage("legacy5DigitWarning"));
684
+ }
685
+ });
686
+ return schema;
687
+ }
688
+
689
+
690
+
691
+
692
+
693
+
694
+
695
+
696
+ exports.VALID_3_DIGIT_PREFIXES = VALID_3_DIGIT_PREFIXES; exports.validate3DigitPostalCode = validate3DigitPostalCode; exports.validate5DigitPostalCode = validate5DigitPostalCode; exports.validate6DigitPostalCode = validate6DigitPostalCode; exports.validateTaiwanPostalCode = validateTaiwanPostalCode; exports.twPostalCode = twPostalCode;