@validex/core 1.0.0

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 (101) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +583 -0
  3. package/dist/checks/index.cjs +51 -0
  4. package/dist/checks/index.d.cts +207 -0
  5. package/dist/checks/index.d.ts +207 -0
  6. package/dist/checks/index.js +51 -0
  7. package/dist/chunk-2OTGUKO7.cjs +26 -0
  8. package/dist/chunk-4HUGF4EZ.js +0 -0
  9. package/dist/chunk-5CYBSNNG.cjs +33 -0
  10. package/dist/chunk-5DOFRLSB.js +30 -0
  11. package/dist/chunk-64X6D23X.cjs +24 -0
  12. package/dist/chunk-6MGS4JWP.js +152 -0
  13. package/dist/chunk-AGJWIOFF.js +24 -0
  14. package/dist/chunk-BAFEYOPS.js +43 -0
  15. package/dist/chunk-BYMZTDYD.js +56 -0
  16. package/dist/chunk-D232V332.cjs +30 -0
  17. package/dist/chunk-FD77PZXB.js +9 -0
  18. package/dist/chunk-H3XHQLZF.cjs +43 -0
  19. package/dist/chunk-ISY3F7TI.cjs +239 -0
  20. package/dist/chunk-JEKRBIPN.cjs +1 -0
  21. package/dist/chunk-KTN4NQQL.js +33 -0
  22. package/dist/chunk-LSQNDPFQ.cjs +9 -0
  23. package/dist/chunk-NDLUDRZJ.js +24 -0
  24. package/dist/chunk-OCTLUBGT.cjs +24 -0
  25. package/dist/chunk-OFT3FQPJ.cjs +152 -0
  26. package/dist/chunk-OOFMB7K5.js +34 -0
  27. package/dist/chunk-OTPQTLPM.js +50 -0
  28. package/dist/chunk-P3FRVJ3U.cjs +50 -0
  29. package/dist/chunk-PFPNNQGJ.js +30 -0
  30. package/dist/chunk-PQ4TUE2Q.cjs +2688 -0
  31. package/dist/chunk-SMDC2EAD.js +26 -0
  32. package/dist/chunk-TB6J73U7.js +239 -0
  33. package/dist/chunk-TBVAKZA5.js +2688 -0
  34. package/dist/chunk-TSPTIW3V.cjs +34 -0
  35. package/dist/chunk-WE2OD5XD.cjs +30 -0
  36. package/dist/chunk-WKVMDEA3.js +26 -0
  37. package/dist/chunk-ZAUX2RGL.cjs +56 -0
  38. package/dist/chunk-ZWIO2MJX.cjs +26 -0
  39. package/dist/cli/index.cjs +120 -0
  40. package/dist/cli/index.d.cts +1 -0
  41. package/dist/cli/index.d.ts +1 -0
  42. package/dist/cli/index.js +120 -0
  43. package/dist/commonPasswords-3BYUBARZ.cjs +10 -0
  44. package/dist/commonPasswords-ZYOEI6PG.js +10 -0
  45. package/dist/countryCodes-EKJKVHR5.cjs +10 -0
  46. package/dist/countryCodes-RTJZVCLB.js +10 -0
  47. package/dist/countryCodes-VY56VZPT.cjs +255 -0
  48. package/dist/countryCodes-YRY75MQP.js +255 -0
  49. package/dist/creditCardPrefixes-EXMJZGE7.cjs +10 -0
  50. package/dist/creditCardPrefixes-EZK7T4IZ.js +10 -0
  51. package/dist/creditCardPrefixes-HKWKCHNU.cjs +48 -0
  52. package/dist/creditCardPrefixes-QP3S4ZAU.js +48 -0
  53. package/dist/currencyCodes-GU6W3HSN.cjs +171 -0
  54. package/dist/currencyCodes-P67AASLW.js +171 -0
  55. package/dist/currencyCodes-RMRLGDME.cjs +10 -0
  56. package/dist/currencyCodes-U6TSAWDR.js +10 -0
  57. package/dist/disposableDomains-DCXSV422.js +10 -0
  58. package/dist/disposableDomains-USU2JQSF.cjs +10 -0
  59. package/dist/ibanPatterns-2PM32RIY.cjs +85 -0
  60. package/dist/ibanPatterns-BSQUWKLY.js +85 -0
  61. package/dist/ibanPatterns-KTLY6TZY.cjs +10 -0
  62. package/dist/ibanPatterns-LJRPR7FV.js +10 -0
  63. package/dist/index-Cid7Ygr_.d.cts +950 -0
  64. package/dist/index-Cid7Ygr_.d.ts +950 -0
  65. package/dist/index.cjs +361 -0
  66. package/dist/index.d.cts +132 -0
  67. package/dist/index.d.ts +132 -0
  68. package/dist/index.js +361 -0
  69. package/dist/locales/en.cjs +10 -0
  70. package/dist/locales/en.d.cts +234 -0
  71. package/dist/locales/en.d.ts +234 -0
  72. package/dist/locales/en.js +10 -0
  73. package/dist/passwordsTier1-NAZLSHKW.cjs +105 -0
  74. package/dist/passwordsTier1-OYRMLOWD.js +105 -0
  75. package/dist/passwordsTier2-GYJTYGY6.cjs +906 -0
  76. package/dist/passwordsTier2-JAEO5AYY.js +906 -0
  77. package/dist/passwordsTier3-BAPUFHZM.cjs +9006 -0
  78. package/dist/passwordsTier3-E6WBK5OB.js +9006 -0
  79. package/dist/phoneDetection-AFSSD4IB.cjs +6 -0
  80. package/dist/phoneDetection-G23LZ6MU.js +6 -0
  81. package/dist/phoneParser-2RTXDB6H.js +10 -0
  82. package/dist/phoneParser-CGRP2OUN.cjs +10 -0
  83. package/dist/postalCodes-4EZVDT2N.cjs +10 -0
  84. package/dist/postalCodes-ZPAJB3P5.js +10 -0
  85. package/dist/reservedUsernames-3QPPKUXR.cjs +246 -0
  86. package/dist/reservedUsernames-GIK6NX3J.js +246 -0
  87. package/dist/reservedUsernames-QR4ONXSL.js +10 -0
  88. package/dist/reservedUsernames-W65FGT6A.cjs +10 -0
  89. package/dist/rules/index.cjs +66 -0
  90. package/dist/rules/index.d.cts +2 -0
  91. package/dist/rules/index.d.ts +2 -0
  92. package/dist/rules/index.js +66 -0
  93. package/dist/utilities/index.cjs +8 -0
  94. package/dist/utilities/index.d.cts +47 -0
  95. package/dist/utilities/index.d.ts +47 -0
  96. package/dist/utilities/index.js +8 -0
  97. package/dist/vatPatterns-BLRXHNCP.js +36 -0
  98. package/dist/vatPatterns-DNVZJPTW.js +10 -0
  99. package/dist/vatPatterns-NPN6SV2Y.cjs +36 -0
  100. package/dist/vatPatterns-RRHUTA3U.cjs +10 -0
  101. package/package.json +133 -0
@@ -0,0 +1,2688 @@
1
+ import {
2
+ getCreditCardPrefixes,
3
+ loadCreditCardPrefixes
4
+ } from "./chunk-OOFMB7K5.js";
5
+ import {
6
+ getPostalCodes,
7
+ loadPostalCodes
8
+ } from "./chunk-NDLUDRZJ.js";
9
+ import {
10
+ getCountryCodes,
11
+ loadCountryCodes
12
+ } from "./chunk-PFPNNQGJ.js";
13
+ import {
14
+ getCurrencyCodes,
15
+ loadCurrencyCodes
16
+ } from "./chunk-SMDC2EAD.js";
17
+ import {
18
+ getIbanPatterns,
19
+ loadIbanPatterns
20
+ } from "./chunk-KTN4NQQL.js";
21
+ import {
22
+ getVatPatterns,
23
+ loadVatPatterns
24
+ } from "./chunk-5DOFRLSB.js";
25
+ import {
26
+ getCommonPasswords,
27
+ loadCommonPasswords
28
+ } from "./chunk-OTPQTLPM.js";
29
+ import {
30
+ getReservedUsernames,
31
+ loadReservedUsernames
32
+ } from "./chunk-WKVMDEA3.js";
33
+ import {
34
+ loadPhoneParser
35
+ } from "./chunk-BYMZTDYD.js";
36
+ import {
37
+ collapseWhitespace,
38
+ containsEmail,
39
+ containsHtml,
40
+ containsUrl,
41
+ hasDigits,
42
+ hasLowercase,
43
+ hasSpecial,
44
+ hasUppercase,
45
+ maxConsecutive,
46
+ maxWords,
47
+ minWords,
48
+ noSpaces,
49
+ onlyAlpha,
50
+ onlyAlphaSpaceHyphen,
51
+ onlyAlphanumeric,
52
+ onlyAlphanumericSpaceHyphen,
53
+ onlyNumeric,
54
+ stripHtml,
55
+ toSlug,
56
+ toTitleCase
57
+ } from "./chunk-6MGS4JWP.js";
58
+ import {
59
+ en_default
60
+ } from "./chunk-TB6J73U7.js";
61
+ import {
62
+ getDisposableDomains
63
+ } from "./chunk-AGJWIOFF.js";
64
+
65
+ // src/rules/businessName.ts
66
+ import { z as z3 } from "zod";
67
+
68
+ // src/core/createRule.ts
69
+ import { z as z2 } from "zod";
70
+
71
+ // src/augmentation/methods.ts
72
+ import { ZodType } from "zod";
73
+
74
+ // src/core/customError.ts
75
+ import { z } from "zod";
76
+
77
+ // src/config/store.ts
78
+ var DEFAULT_I18N = {
79
+ enabled: false,
80
+ prefix: "validation",
81
+ separator: ".",
82
+ pathMode: "semantic"
83
+ };
84
+ var DEFAULT_CONFIG = {
85
+ i18n: DEFAULT_I18N,
86
+ label: { fallback: "derived" }
87
+ };
88
+ var config = { ...DEFAULT_CONFIG, i18n: { ...DEFAULT_I18N } };
89
+ var initialized = false;
90
+ function getConfig() {
91
+ return config;
92
+ }
93
+ function setConfig(newConfig) {
94
+ config = newConfig;
95
+ initialized = true;
96
+ }
97
+ function isInitialized() {
98
+ return initialized;
99
+ }
100
+ function resetConfig() {
101
+ config = { ...DEFAULT_CONFIG, i18n: { ...DEFAULT_I18N } };
102
+ initialized = false;
103
+ _resetCustomErrorFlag();
104
+ }
105
+
106
+ // src/core/errorMap.ts
107
+ var TEMPLATE_PARAM_RE = /\{\{(\w+)\}\}/g;
108
+ var MESSAGE_MAP = en_default.validation.messages;
109
+ function getErrorMessage(namespace, code, params = {}) {
110
+ const nsMap = MESSAGE_MAP[namespace];
111
+ const template = nsMap?.[code] ?? MESSAGE_MAP["base"]?.["format"] ?? "";
112
+ return template.replace(TEMPLATE_PARAM_RE, (_match, key) => {
113
+ const value = params[key];
114
+ return value !== void 0 && value !== null ? String(value) : `{{${key}}}`;
115
+ });
116
+ }
117
+ function buildMessageKey(prefix, separator, namespace, code, pathMode = "semantic", path = []) {
118
+ if (typeof pathMode === "function") {
119
+ const transformed = pathMode(path);
120
+ return [prefix, "messages", transformed, namespace, code].join(separator);
121
+ }
122
+ if (pathMode === "key" && path.length > 0) {
123
+ const last = String(path.at(-1));
124
+ return [prefix, "messages", last, namespace, code].join(separator);
125
+ }
126
+ if (pathMode === "full" && path.length > 0) {
127
+ const pathSegments = path.map(String);
128
+ return [prefix, "messages", ...pathSegments, namespace, code].join(separator);
129
+ }
130
+ return [prefix, "messages", namespace, code].join(separator);
131
+ }
132
+ function registerMessages(namespace, messages) {
133
+ const existing = MESSAGE_MAP[namespace];
134
+ MESSAGE_MAP[namespace] = { ...existing, ...messages };
135
+ }
136
+
137
+ // src/internal/fieldLabel.ts
138
+ var CAMEL_SPLIT_RE = /([a-z])([A-Z])/g;
139
+ var SEPARATOR_RE = /[_-]/g;
140
+ var WORD_START_RE = /\b\w/g;
141
+ function fieldNameToLabel(str) {
142
+ return str.replace(CAMEL_SPLIT_RE, "$1 $2").replace(SEPARATOR_RE, " ").replace(WORD_START_RE, (c) => c.toUpperCase());
143
+ }
144
+
145
+ // src/core/getParams.ts
146
+ function mapNativeCode(issue) {
147
+ const issueCode = issue.code;
148
+ if (issueCode === void 0)
149
+ return void 0;
150
+ const ns = "base";
151
+ const mapping = {
152
+ too_small: () => issue.minimum === 1 ? { namespace: ns, code: "required" } : { namespace: ns, code: "min" },
153
+ too_big: () => ({ namespace: ns, code: "max" }),
154
+ invalid_type: () => issue.received === "undefined" || issue.input === void 0 ? { namespace: ns, code: "required" } : { namespace: ns, code: "type" },
155
+ invalid_format: () => ({ namespace: ns, code: "format" }),
156
+ invalid_string: () => ({ namespace: ns, code: "format" })
157
+ };
158
+ const factory = mapping[issueCode];
159
+ return factory !== void 0 ? factory() : void 0;
160
+ }
161
+ function deriveLabel(path, explicitLabel) {
162
+ if (explicitLabel !== void 0)
163
+ return explicitLabel;
164
+ const config2 = getConfig();
165
+ const fallback = config2.label?.fallback ?? "derived";
166
+ let defaultLabel;
167
+ if (fallback === "none") {
168
+ defaultLabel = "";
169
+ } else if (fallback === "generic") {
170
+ defaultLabel = "This field";
171
+ } else {
172
+ const last = path.at(-1);
173
+ if (last === void 0) {
174
+ defaultLabel = "This field";
175
+ } else {
176
+ defaultLabel = typeof last === "string" ? fieldNameToLabel(last) : `Item ${String(last)}`;
177
+ }
178
+ }
179
+ if (config2.label?.transform !== void 0) {
180
+ const last = path.at(-1);
181
+ const fieldName = last !== void 0 ? String(last) : "";
182
+ return config2.label.transform({ path, fieldName, defaultLabel });
183
+ }
184
+ return defaultLabel;
185
+ }
186
+ function resolveI18nLabel(label, labelKey, explicitLabel, config2) {
187
+ if (explicitLabel !== void 0 || config2.label?.transform !== void 0 || config2.i18n.t === void 0) {
188
+ return label;
189
+ }
190
+ const translated = config2.i18n.t(labelKey);
191
+ return translated !== labelKey && translated !== "" ? translated : label;
192
+ }
193
+ function getParams(issue) {
194
+ const path = issue.path ?? [];
195
+ const params = issue.params ?? {};
196
+ const validexCode = params["code"];
197
+ const validexNs = params["namespace"];
198
+ const hasValidex = validexCode !== void 0 && validexNs !== void 0;
199
+ const native = hasValidex ? void 0 : mapNativeCode(issue);
200
+ const namespace = validexNs ?? native?.namespace ?? "base";
201
+ const code = validexCode ?? native?.code ?? "format";
202
+ const explicitLabel = params["label"];
203
+ const label = deriveLabel(path, explicitLabel);
204
+ const config2 = getConfig();
205
+ const i18n = config2.i18n;
206
+ const prefix = i18n.prefix ?? "validation";
207
+ const separator = i18n.separator ?? ".";
208
+ const pathMode = i18n.pathMode ?? "semantic";
209
+ const key = buildMessageKey(prefix, separator, namespace, code, pathMode, path);
210
+ const extra = {};
211
+ for (const [k, v] of Object.entries(params)) {
212
+ if (k !== "code" && k !== "namespace" && k !== "label") {
213
+ extra[k] = v;
214
+ }
215
+ }
216
+ if (issue.minimum !== void 0)
217
+ extra["minimum"] = issue.minimum;
218
+ if (issue.maximum !== void 0)
219
+ extra["maximum"] = issue.maximum;
220
+ if (issue.expected !== void 0)
221
+ extra["expected"] = issue.expected;
222
+ const base = {
223
+ code,
224
+ namespace,
225
+ label,
226
+ key,
227
+ path,
228
+ ...extra
229
+ };
230
+ if (i18n.enabled) {
231
+ const labelKey = [prefix, "labels", ...path.map(String)].join(separator);
232
+ const resolvedLabel = resolveI18nLabel(label, labelKey, explicitLabel, config2);
233
+ return { ...base, label: resolvedLabel, labelKey };
234
+ }
235
+ return base;
236
+ }
237
+
238
+ // src/core/customError.ts
239
+ var NATIVE_CODES = /* @__PURE__ */ new Set([
240
+ "too_small",
241
+ "too_big",
242
+ "invalid_type",
243
+ "invalid_format",
244
+ "invalid_string"
245
+ ]);
246
+ function adaptIssue(issue) {
247
+ const rawPath = issue["path"];
248
+ const path = Array.isArray(rawPath) ? rawPath.filter(
249
+ (s) => typeof s === "string" || typeof s === "number"
250
+ ) : void 0;
251
+ return {
252
+ /* v8 ignore start -- defensive ternary guards; Zod always provides code/expected/received as strings when present */
253
+ code: typeof issue["code"] === "string" ? issue["code"] : void 0,
254
+ path,
255
+ minimum: issue["minimum"],
256
+ maximum: issue["maximum"],
257
+ expected: typeof issue["expected"] === "string" ? issue["expected"] : void 0,
258
+ received: typeof issue["received"] === "string" ? issue["received"] : void 0,
259
+ input: issue["input"],
260
+ format: typeof issue["format"] === "string" ? issue["format"] : void 0,
261
+ /* v8 ignore stop */
262
+ // SAFETY: Zod issues have untyped params; narrowed via isValidexIssue guard
263
+ params: issue["params"]
264
+ };
265
+ }
266
+ function isValidexIssue(params) {
267
+ return params["code"] !== void 0 && params["namespace"] !== void 0;
268
+ }
269
+ var _registered = false;
270
+ function ensureCustomError() {
271
+ if (_registered)
272
+ return;
273
+ registerCustomError();
274
+ }
275
+ function registerCustomError() {
276
+ const prev = z.config().customError;
277
+ z.config({
278
+ customError(issue) {
279
+ const adapted = adaptIssue(issue);
280
+ const params = adapted.params ?? {};
281
+ const shouldHandle = isValidexIssue(params) || adapted.code !== void 0 && NATIVE_CODES.has(adapted.code);
282
+ if (!shouldHandle) {
283
+ return prev?.(issue) ?? void 0;
284
+ }
285
+ const errorParams = getParams(adapted);
286
+ const config2 = getConfig();
287
+ const i18n = config2.i18n;
288
+ let msg;
289
+ if (i18n.enabled && i18n.t !== void 0) {
290
+ msg = i18n.t(errorParams.key, { ...errorParams });
291
+ } else if (i18n.enabled) {
292
+ msg = errorParams.key;
293
+ } else {
294
+ msg = getErrorMessage(
295
+ errorParams.namespace,
296
+ errorParams.code,
297
+ { ...errorParams }
298
+ );
299
+ }
300
+ if (config2.message?.transform !== void 0) {
301
+ msg = config2.message.transform({
302
+ key: errorParams.key,
303
+ code: errorParams.code,
304
+ namespace: errorParams.namespace,
305
+ path: errorParams.path,
306
+ label: errorParams.label,
307
+ message: msg,
308
+ params: { ...errorParams }
309
+ });
310
+ }
311
+ return { message: msg };
312
+ }
313
+ });
314
+ _registered = true;
315
+ }
316
+ function _resetCustomErrorFlag() {
317
+ _registered = false;
318
+ }
319
+
320
+ // src/augmentation/methods.ts
321
+ var _initialized = false;
322
+ function initAugmentation() {
323
+ if (_initialized)
324
+ return;
325
+ _initialized = true;
326
+ ensureCustomError();
327
+ ZodType.prototype.hasUppercase = function(opts = {}) {
328
+ const min = opts.min ?? 1;
329
+ const max = opts.max;
330
+ const ns = opts.namespace ?? "string";
331
+ const lbl = opts.label;
332
+ return this.superRefine((v, ctx) => {
333
+ if (typeof v !== "string")
334
+ return;
335
+ if (min > 0 && !hasUppercase(v, min)) {
336
+ ctx.addIssue({ code: "custom", params: { code: "minUppercase", namespace: ns, minimum: min, label: lbl } });
337
+ }
338
+ if (max !== void 0 && !hasUppercase(v, 0, max)) {
339
+ ctx.addIssue({ code: "custom", params: { code: "maxUppercase", namespace: ns, maximum: max, label: lbl } });
340
+ }
341
+ });
342
+ };
343
+ ZodType.prototype.hasLowercase = function(opts = {}) {
344
+ const min = opts.min ?? 1;
345
+ const max = opts.max;
346
+ const ns = opts.namespace ?? "string";
347
+ const lbl = opts.label;
348
+ return this.superRefine((v, ctx) => {
349
+ if (typeof v !== "string")
350
+ return;
351
+ if (min > 0 && !hasLowercase(v, min)) {
352
+ ctx.addIssue({ code: "custom", params: { code: "minLowercase", namespace: ns, minimum: min, label: lbl } });
353
+ }
354
+ if (max !== void 0 && !hasLowercase(v, 0, max)) {
355
+ ctx.addIssue({ code: "custom", params: { code: "maxLowercase", namespace: ns, maximum: max, label: lbl } });
356
+ }
357
+ });
358
+ };
359
+ ZodType.prototype.hasDigits = function(opts = {}) {
360
+ const min = opts.min ?? 1;
361
+ const max = opts.max;
362
+ const ns = opts.namespace ?? "string";
363
+ const lbl = opts.label;
364
+ return this.superRefine((v, ctx) => {
365
+ if (typeof v !== "string")
366
+ return;
367
+ if (min > 0 && !hasDigits(v, min)) {
368
+ ctx.addIssue({ code: "custom", params: { code: "minDigits", namespace: ns, minimum: min, label: lbl } });
369
+ }
370
+ if (max !== void 0 && !hasDigits(v, 0, max)) {
371
+ ctx.addIssue({ code: "custom", params: { code: "maxDigits", namespace: ns, maximum: max, label: lbl } });
372
+ }
373
+ });
374
+ };
375
+ ZodType.prototype.hasSpecial = function(opts = {}) {
376
+ const min = opts.min ?? 1;
377
+ const max = opts.max;
378
+ const ns = opts.namespace ?? "string";
379
+ const lbl = opts.label;
380
+ return this.superRefine((v, ctx) => {
381
+ if (typeof v !== "string")
382
+ return;
383
+ if (min > 0 && !hasSpecial(v, min)) {
384
+ ctx.addIssue({ code: "custom", params: { code: "minSpecial", namespace: ns, minimum: min, label: lbl } });
385
+ }
386
+ if (max !== void 0 && !hasSpecial(v, 0, max)) {
387
+ ctx.addIssue({ code: "custom", params: { code: "maxSpecial", namespace: ns, maximum: max, label: lbl } });
388
+ }
389
+ });
390
+ };
391
+ ZodType.prototype.noEmails = function(opts = {}) {
392
+ const ns = opts.namespace ?? "string";
393
+ const lbl = opts.label;
394
+ return this.superRefine((v, ctx) => {
395
+ if (typeof v !== "string")
396
+ return;
397
+ if (containsEmail(v)) {
398
+ ctx.addIssue({ code: "custom", params: { code: "noEmails", namespace: ns, label: lbl } });
399
+ }
400
+ });
401
+ };
402
+ ZodType.prototype.noUrls = function(opts = {}) {
403
+ const ns = opts.namespace ?? "string";
404
+ const lbl = opts.label;
405
+ return this.superRefine((v, ctx) => {
406
+ if (typeof v !== "string")
407
+ return;
408
+ if (containsUrl(v)) {
409
+ ctx.addIssue({ code: "custom", params: { code: "noUrls", namespace: ns, label: lbl } });
410
+ }
411
+ });
412
+ };
413
+ ZodType.prototype.noHtml = function(opts = {}) {
414
+ const ns = opts.namespace ?? "string";
415
+ const lbl = opts.label;
416
+ return this.superRefine((v, ctx) => {
417
+ if (typeof v !== "string")
418
+ return;
419
+ if (containsHtml(v)) {
420
+ ctx.addIssue({ code: "custom", params: { code: "noHtml", namespace: ns, label: lbl } });
421
+ }
422
+ });
423
+ };
424
+ ZodType.prototype.noPhoneNumbers = function(opts = {}) {
425
+ const ns = opts.namespace ?? "string";
426
+ const lbl = opts.label;
427
+ return this.superRefine(async (v, ctx) => {
428
+ if (typeof v !== "string")
429
+ return;
430
+ const { containsPhoneNumber } = await import("./phoneDetection-G23LZ6MU.js");
431
+ if (await containsPhoneNumber(v)) {
432
+ ctx.addIssue({ code: "custom", params: { code: "noPhoneNumbers", namespace: ns, label: lbl } });
433
+ }
434
+ });
435
+ };
436
+ ZodType.prototype.noSpaces = function(opts = {}) {
437
+ const ns = opts.namespace ?? "string";
438
+ const lbl = opts.label;
439
+ return this.superRefine((v, ctx) => {
440
+ if (typeof v !== "string")
441
+ return;
442
+ if (!noSpaces(v)) {
443
+ ctx.addIssue({ code: "custom", params: { code: "noSpaces", namespace: ns, label: lbl } });
444
+ }
445
+ });
446
+ };
447
+ ZodType.prototype.onlyAlpha = function(opts = {}) {
448
+ const ns = opts.namespace ?? "string";
449
+ const lbl = opts.label;
450
+ return this.superRefine((v, ctx) => {
451
+ if (typeof v !== "string")
452
+ return;
453
+ if (!onlyAlpha(v)) {
454
+ ctx.addIssue({ code: "custom", params: { code: "onlyAlpha", namespace: ns, label: lbl } });
455
+ }
456
+ });
457
+ };
458
+ ZodType.prototype.onlyNumeric = function(opts = {}) {
459
+ const ns = opts.namespace ?? "string";
460
+ const lbl = opts.label;
461
+ return this.superRefine((v, ctx) => {
462
+ if (typeof v !== "string")
463
+ return;
464
+ if (!onlyNumeric(v)) {
465
+ ctx.addIssue({ code: "custom", params: { code: "onlyNumeric", namespace: ns, label: lbl } });
466
+ }
467
+ });
468
+ };
469
+ ZodType.prototype.onlyAlphanumeric = function(opts = {}) {
470
+ const ns = opts.namespace ?? "string";
471
+ const lbl = opts.label;
472
+ return this.superRefine((v, ctx) => {
473
+ if (typeof v !== "string")
474
+ return;
475
+ if (!onlyAlphanumeric(v)) {
476
+ ctx.addIssue({ code: "custom", params: { code: "onlyAlphanumeric", namespace: ns, label: lbl } });
477
+ }
478
+ });
479
+ };
480
+ ZodType.prototype.onlyAlphaSpaceHyphen = function(opts = {}) {
481
+ const ns = opts.namespace ?? "string";
482
+ const lbl = opts.label;
483
+ return this.superRefine((v, ctx) => {
484
+ if (typeof v !== "string")
485
+ return;
486
+ if (!onlyAlphaSpaceHyphen(v)) {
487
+ ctx.addIssue({ code: "custom", params: { code: "onlyAlphaSpaceHyphen", namespace: ns, label: lbl } });
488
+ }
489
+ });
490
+ };
491
+ ZodType.prototype.onlyAlphanumericSpaceHyphen = function(opts = {}) {
492
+ const ns = opts.namespace ?? "string";
493
+ const lbl = opts.label;
494
+ return this.superRefine((v, ctx) => {
495
+ if (typeof v !== "string")
496
+ return;
497
+ if (!onlyAlphanumericSpaceHyphen(v)) {
498
+ ctx.addIssue({ code: "custom", params: { code: "onlyAlphanumericSpaceHyphen", namespace: ns, label: lbl } });
499
+ }
500
+ });
501
+ };
502
+ ZodType.prototype.maxWords = function(opts) {
503
+ const ns = opts.namespace ?? "string";
504
+ const lbl = opts.label;
505
+ const max = opts.max;
506
+ return this.superRefine((v, ctx) => {
507
+ if (typeof v !== "string")
508
+ return;
509
+ if (!maxWords(v, max)) {
510
+ ctx.addIssue({ code: "custom", params: { code: "maxWords", namespace: ns, maximum: max, label: lbl } });
511
+ }
512
+ });
513
+ };
514
+ ZodType.prototype.minWords = function(opts) {
515
+ const ns = opts.namespace ?? "string";
516
+ const lbl = opts.label;
517
+ const min = opts.min;
518
+ return this.superRefine((v, ctx) => {
519
+ if (typeof v !== "string")
520
+ return;
521
+ if (!minWords(v, min)) {
522
+ ctx.addIssue({ code: "custom", params: { code: "minWords", namespace: ns, minimum: min, label: lbl } });
523
+ }
524
+ });
525
+ };
526
+ ZodType.prototype.maxConsecutive = function(opts) {
527
+ const ns = opts.namespace ?? "string";
528
+ const lbl = opts.label;
529
+ const max = opts.max;
530
+ return this.superRefine((v, ctx) => {
531
+ if (typeof v !== "string")
532
+ return;
533
+ if (!maxConsecutive(v, max)) {
534
+ ctx.addIssue({ code: "custom", params: { code: "maxConsecutive", namespace: ns, maximum: max, label: lbl } });
535
+ }
536
+ });
537
+ };
538
+ ZodType.prototype.toTitleCase = function() {
539
+ return this.transform(
540
+ (v) => typeof v === "string" ? toTitleCase(v) : String(v)
541
+ );
542
+ };
543
+ ZodType.prototype.toSlug = function() {
544
+ return this.transform(
545
+ (v) => typeof v === "string" ? toSlug(v) : String(v)
546
+ );
547
+ };
548
+ ZodType.prototype.stripHtml = function() {
549
+ return this.transform(
550
+ (v) => typeof v === "string" ? stripHtml(v) : String(v)
551
+ );
552
+ };
553
+ ZodType.prototype.collapseWhitespace = function() {
554
+ return this.transform(
555
+ (v) => typeof v === "string" ? collapseWhitespace(v) : String(v)
556
+ );
557
+ };
558
+ ZodType.prototype.emptyToUndefined = function() {
559
+ return this.transform(
560
+ (v) => v === "" || v === null ? void 0 : v
561
+ );
562
+ };
563
+ }
564
+
565
+ // src/config/defaults.ts
566
+ var RULE_DEFAULTS = {
567
+ email: {
568
+ length: { max: 254 },
569
+ blockPlusAlias: false,
570
+ blockDomains: [],
571
+ allowDomains: [],
572
+ blockDisposable: false,
573
+ allowSubdomains: true,
574
+ emptyToUndefined: true,
575
+ normalize: true
576
+ },
577
+ personName: {
578
+ length: { min: 2, max: 50 },
579
+ words: { max: 5 },
580
+ allowUnicode: true,
581
+ boundary: "alpha",
582
+ consecutive: { max: 3 },
583
+ titleCase: false,
584
+ emptyToUndefined: true,
585
+ normalize: true
586
+ },
587
+ businessName: {
588
+ length: { min: 2, max: 100 },
589
+ boundary: "alphanumeric",
590
+ consecutive: { max: 4 },
591
+ titleCase: false,
592
+ emptyToUndefined: true,
593
+ normalize: true
594
+ },
595
+ password: {
596
+ length: { min: 8, max: 128 },
597
+ uppercase: { min: 1 },
598
+ lowercase: { min: 1 },
599
+ digits: { min: 1 },
600
+ special: { min: 1 },
601
+ consecutive: { max: 3 },
602
+ blockCommon: false,
603
+ emptyToUndefined: true,
604
+ normalize: true
605
+ },
606
+ passwordConfirmation: {
607
+ passwordField: "password",
608
+ emptyToUndefined: true,
609
+ normalize: true
610
+ },
611
+ phone: {
612
+ allowCountries: [],
613
+ blockCountries: [],
614
+ requireMobile: false,
615
+ requireCountryCode: false,
616
+ format: "e164",
617
+ metadata: "min",
618
+ emptyToUndefined: true,
619
+ normalize: true
620
+ },
621
+ website: {
622
+ length: { max: 255 },
623
+ requireWww: false,
624
+ requireHttps: false,
625
+ allowDomains: [],
626
+ blockDomains: [],
627
+ allowSubdomains: true,
628
+ allowPath: true,
629
+ allowQuery: false,
630
+ emptyToUndefined: true,
631
+ normalize: true
632
+ },
633
+ url: {
634
+ protocols: ["http", "https"],
635
+ requireTLD: true,
636
+ length: { max: 2048 },
637
+ allowDomains: [],
638
+ blockDomains: [],
639
+ allowQuery: true,
640
+ allowAuth: false,
641
+ emptyToUndefined: true,
642
+ normalize: true
643
+ },
644
+ username: {
645
+ length: { min: 3, max: 20 },
646
+ pattern: "alphanumeric-underscore",
647
+ boundary: "alphanumeric",
648
+ ignoreCase: true,
649
+ blockReserved: false,
650
+ reservedWords: [],
651
+ emptyToUndefined: true,
652
+ normalize: true
653
+ },
654
+ slug: {
655
+ length: { min: 3, max: 100 },
656
+ emptyToUndefined: true,
657
+ normalize: true
658
+ },
659
+ postalCode: {
660
+ emptyToUndefined: true,
661
+ normalize: true
662
+ },
663
+ licenseKey: {
664
+ type: "custom",
665
+ segments: 5,
666
+ segmentLength: 5,
667
+ separator: "-",
668
+ charset: "alphanumeric",
669
+ emptyToUndefined: true,
670
+ normalize: true
671
+ },
672
+ uuid: {
673
+ version: "any",
674
+ emptyToUndefined: true,
675
+ normalize: true
676
+ },
677
+ jwt: {
678
+ requireExpiry: false,
679
+ checkExpiry: false,
680
+ checkNotBefore: false,
681
+ clockTolerance: 0,
682
+ emptyToUndefined: true,
683
+ normalize: true
684
+ },
685
+ dateTime: {
686
+ format: "iso",
687
+ allowFuture: true,
688
+ allowPast: true,
689
+ allowOffset: true,
690
+ allowLocal: false,
691
+ emptyToUndefined: true,
692
+ normalize: true
693
+ },
694
+ token: {
695
+ emptyToUndefined: true,
696
+ normalize: true
697
+ },
698
+ text: {
699
+ noEmails: false,
700
+ noUrls: false,
701
+ noPhoneNumbers: false,
702
+ noHtml: false,
703
+ emptyToUndefined: true,
704
+ normalize: true
705
+ },
706
+ country: {
707
+ format: "alpha2",
708
+ allowCountries: [],
709
+ blockCountries: [],
710
+ emptyToUndefined: true,
711
+ normalize: true
712
+ },
713
+ currency: {
714
+ allowCurrencies: [],
715
+ blockCurrencies: [],
716
+ emptyToUndefined: true,
717
+ normalize: true
718
+ },
719
+ color: {
720
+ format: "hex",
721
+ alpha: true,
722
+ emptyToUndefined: true,
723
+ normalize: true
724
+ },
725
+ creditCard: {
726
+ emptyToUndefined: true,
727
+ normalize: true
728
+ },
729
+ iban: {
730
+ allowCountries: [],
731
+ blockCountries: [],
732
+ emptyToUndefined: true,
733
+ normalize: true
734
+ },
735
+ vatNumber: {
736
+ requirePrefix: false,
737
+ emptyToUndefined: true,
738
+ normalize: true
739
+ },
740
+ macAddress: {
741
+ delimiter: ":",
742
+ emptyToUndefined: true,
743
+ normalize: true
744
+ },
745
+ ipAddress: {
746
+ version: "any",
747
+ allowCidr: false,
748
+ allowPrivate: true,
749
+ emptyToUndefined: true,
750
+ normalize: true
751
+ }
752
+ };
753
+
754
+ // src/config/merge.ts
755
+ function isPlainObject(value) {
756
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof RegExp) && !(value instanceof Date);
757
+ }
758
+ function deepMergeTwo(base, override) {
759
+ const result = { ...base };
760
+ for (const key of Object.keys(override)) {
761
+ const overrideValue = override[key];
762
+ if (overrideValue === void 0) {
763
+ delete result[key];
764
+ continue;
765
+ }
766
+ const baseValue = base[key];
767
+ if (isPlainObject(baseValue) && isPlainObject(overrideValue)) {
768
+ result[key] = deepMergeTwo(baseValue, overrideValue);
769
+ } else {
770
+ result[key] = overrideValue;
771
+ }
772
+ }
773
+ return result;
774
+ }
775
+ function mergeThreeTiers(defaults, globals, perCall) {
776
+ const afterGlobals = deepMergeTwo(defaults, globals);
777
+ return deepMergeTwo(afterGlobals, perCall);
778
+ }
779
+
780
+ // src/config/index.ts
781
+ function configure(config2) {
782
+ const current = getConfig();
783
+ const merged = deepMergeTwo(
784
+ current,
785
+ config2
786
+ );
787
+ setConfig(merged);
788
+ }
789
+ function setup(config2) {
790
+ if (config2 !== void 0) {
791
+ configure(config2);
792
+ } else if (!isInitialized()) {
793
+ setConfig(getConfig());
794
+ }
795
+ initAugmentation();
796
+ }
797
+ function getConfig2() {
798
+ return getConfig();
799
+ }
800
+ async function preloadData(options) {
801
+ const tasks = [];
802
+ if (options.disposable === true) {
803
+ const { loadDisposableDomains } = await import("./disposableDomains-DCXSV422.js");
804
+ tasks.push(loadDisposableDomains());
805
+ }
806
+ if (options.passwords !== void 0 && options.passwords !== false) {
807
+ const tier = options.passwords === true ? "basic" : options.passwords;
808
+ const { loadCommonPasswords: loadCommonPasswords2 } = await import("./commonPasswords-ZYOEI6PG.js");
809
+ tasks.push(loadCommonPasswords2(tier));
810
+ }
811
+ if (options.reserved === true) {
812
+ const { loadReservedUsernames: loadReservedUsernames2 } = await import("./reservedUsernames-QR4ONXSL.js");
813
+ tasks.push(loadReservedUsernames2());
814
+ }
815
+ if (options.phone !== void 0) {
816
+ const { loadPhoneParser: loadPhoneParser2 } = await import("./phoneParser-2RTXDB6H.js");
817
+ tasks.push(loadPhoneParser2(options.phone));
818
+ }
819
+ if (options.countryCodes === true) {
820
+ const { loadCountryCodes: loadCountryCodes2 } = await import("./countryCodes-RTJZVCLB.js");
821
+ tasks.push(loadCountryCodes2());
822
+ }
823
+ if (options.currencyCodes === true) {
824
+ const { loadCurrencyCodes: loadCurrencyCodes2 } = await import("./currencyCodes-U6TSAWDR.js");
825
+ tasks.push(loadCurrencyCodes2());
826
+ }
827
+ if (options.ibanPatterns === true) {
828
+ const { loadIbanPatterns: loadIbanPatterns2 } = await import("./ibanPatterns-LJRPR7FV.js");
829
+ tasks.push(loadIbanPatterns2());
830
+ }
831
+ if (options.vatPatterns === true) {
832
+ const { loadVatPatterns: loadVatPatterns2 } = await import("./vatPatterns-DNVZJPTW.js");
833
+ tasks.push(loadVatPatterns2());
834
+ }
835
+ if (options.creditCardPrefixes === true) {
836
+ const { loadCreditCardPrefixes: loadCreditCardPrefixes2 } = await import("./creditCardPrefixes-EZK7T4IZ.js");
837
+ tasks.push(loadCreditCardPrefixes2());
838
+ }
839
+ if (options.postalCodes === true) {
840
+ const { loadPostalCodes: loadPostalCodes2 } = await import("./postalCodes-ZPAJB3P5.js");
841
+ tasks.push(loadPostalCodes2());
842
+ }
843
+ await Promise.all(tasks);
844
+ }
845
+
846
+ // src/core/crossFieldRegistry.ts
847
+ var registry = /* @__PURE__ */ new WeakMap();
848
+ function registerCrossField(schema, meta) {
849
+ registry.set(schema, meta);
850
+ }
851
+ function getCrossField(schema) {
852
+ return registry.get(schema);
853
+ }
854
+
855
+ // src/core/createRule.ts
856
+ var RESERVED_NAMESPACES = ["base", "string", "confirmation"];
857
+ var FALLBACK_MESSAGE = "Validation failed";
858
+ function assertNotReserved(name) {
859
+ if (RESERVED_NAMESPACES.includes(name)) {
860
+ throw new Error(
861
+ `validex: "${name}" is a reserved namespace and cannot be used as a rule name`
862
+ );
863
+ }
864
+ }
865
+ function applyEmptyToUndefined(schema, label) {
866
+ return z2.preprocess(
867
+ (val) => {
868
+ if (val === "")
869
+ return void 0;
870
+ if (val === null)
871
+ return void 0;
872
+ return val;
873
+ },
874
+ z2.unknown().superRefine((val, ctx) => {
875
+ if (val === void 0 || val === null) {
876
+ ctx.addIssue({ code: "custom", params: { code: "required", namespace: "base", label } });
877
+ }
878
+ }).pipe(schema)
879
+ );
880
+ }
881
+ function applyCustomFn(schema, customFn, namespace, label) {
882
+ return schema.superRefine(async (value, ctx) => {
883
+ if (typeof value !== "string")
884
+ return;
885
+ const result = await customFn(value);
886
+ if (result === true)
887
+ return;
888
+ const errorMsg = typeof result === "string" ? result : FALLBACK_MESSAGE;
889
+ const params = { code: "custom", namespace };
890
+ if (label !== void 0)
891
+ params["label"] = label;
892
+ ctx.addIssue({
893
+ code: "custom",
894
+ message: errorMsg,
895
+ params
896
+ });
897
+ });
898
+ }
899
+ function createRule(config2) {
900
+ assertNotReserved(config2.name);
901
+ let messagesRegistered = false;
902
+ return (options) => {
903
+ initAugmentation();
904
+ if (!messagesRegistered) {
905
+ if (Object.keys(config2.messages).length > 0) {
906
+ registerMessages(config2.name, config2.messages);
907
+ }
908
+ messagesRegistered = true;
909
+ }
910
+ const tier1Defaults = RULE_DEFAULTS[config2.name] ?? {};
911
+ const tier1 = { ...tier1Defaults, ...config2.defaults };
912
+ const globals = getConfig2().rules?.[config2.name] ?? {};
913
+ const mergedOpts = mergeThreeTiers(
914
+ tier1,
915
+ globals,
916
+ // SAFETY: Options are plain objects flowing through three-tier merge
917
+ options ?? {}
918
+ );
919
+ const baseSchema = config2.build(mergedOpts);
920
+ let schema = mergedOpts.emptyToUndefined !== false ? applyEmptyToUndefined(baseSchema, mergedOpts.label) : baseSchema;
921
+ if (mergedOpts.customFn !== void 0) {
922
+ const customRefine = applyCustomFn(z2.string(), mergedOpts.customFn, config2.name, mergedOpts.label);
923
+ schema = schema.pipe(customRefine);
924
+ }
925
+ if (mergedOpts.sameAs !== void 0 || mergedOpts.requiredWhen !== void 0 || mergedOpts.label !== void 0) {
926
+ registerCrossField(schema, {
927
+ sameAs: mergedOpts.sameAs,
928
+ requiredWhen: mergedOpts.requiredWhen,
929
+ label: mergedOpts.label
930
+ });
931
+ }
932
+ return schema;
933
+ };
934
+ }
935
+
936
+ // src/internal/boundary.ts
937
+ var UNICODE_ALPHA_RE = /^\p{L}$/u;
938
+ var UNICODE_ALPHANUMERIC_RE = /^[\p{L}\p{Nd}]$/u;
939
+ function checkUnicodeBoundary(value, boundary) {
940
+ const chars = Array.from(value);
941
+ const first = chars[0];
942
+ const last = chars.at(-1);
943
+ if (first === void 0 || last === void 0) {
944
+ return false;
945
+ }
946
+ if (boundary.start === "alpha" && !UNICODE_ALPHA_RE.test(first))
947
+ return false;
948
+ if (boundary.start === "alphanumeric" && !UNICODE_ALPHANUMERIC_RE.test(first))
949
+ return false;
950
+ if (boundary.end === "alpha" && !UNICODE_ALPHA_RE.test(last))
951
+ return false;
952
+ if (boundary.end === "alphanumeric" && !UNICODE_ALPHANUMERIC_RE.test(last))
953
+ return false;
954
+ return true;
955
+ }
956
+ var ASCII_ALPHA_RE = /^[a-z]$/;
957
+ var ASCII_ALPHANUMERIC_RE = /^[a-z0-9]$/;
958
+ function checkAsciiBoundary(value, boundary) {
959
+ const first = value.charAt(0);
960
+ const last = value.charAt(value.length - 1);
961
+ if (first === "" || last === "")
962
+ return false;
963
+ if (boundary.start === "alpha" && !ASCII_ALPHA_RE.test(first))
964
+ return false;
965
+ if (boundary.start === "alphanumeric" && !ASCII_ALPHANUMERIC_RE.test(first))
966
+ return false;
967
+ if (boundary.end === "alpha" && !ASCII_ALPHA_RE.test(last))
968
+ return false;
969
+ if (boundary.end === "alphanumeric" && !ASCII_ALPHANUMERIC_RE.test(last))
970
+ return false;
971
+ return true;
972
+ }
973
+
974
+ // src/internal/escapeRegex.ts
975
+ var ESCAPE_REGEX_RE = /[-.*+?^${}()|[\]\\]/g;
976
+ function escapeRegexChars(str) {
977
+ return str.replace(ESCAPE_REGEX_RE, "\\$&");
978
+ }
979
+
980
+ // src/internal/resolveBoundary.ts
981
+ function resolveBoundary(value) {
982
+ if (value === void 0) {
983
+ return void 0;
984
+ }
985
+ if (typeof value === "string") {
986
+ return { start: value, end: value };
987
+ }
988
+ return {
989
+ start: value.start ?? "any",
990
+ end: value.end ?? "any"
991
+ };
992
+ }
993
+
994
+ // src/internal/resolveRange.ts
995
+ function resolveRange(value) {
996
+ if (value === void 0) {
997
+ return void 0;
998
+ }
999
+ if (typeof value === "number") {
1000
+ return { min: value, max: value };
1001
+ }
1002
+ const result = {};
1003
+ if (value.min !== void 0) {
1004
+ result.min = value.min;
1005
+ }
1006
+ if (value.max !== void 0) {
1007
+ result.max = value.max;
1008
+ }
1009
+ return result;
1010
+ }
1011
+
1012
+ // src/rules/businessName.ts
1013
+ var DEFAULT_EXTRA = " &.,-'()";
1014
+ function buildBusinessCharsetRegex(extraChars, disallowChars) {
1015
+ let allowed = DEFAULT_EXTRA;
1016
+ if (extraChars !== void 0) {
1017
+ allowed += extraChars;
1018
+ }
1019
+ if (disallowChars !== void 0) {
1020
+ for (const ch of disallowChars) {
1021
+ allowed = allowed.replaceAll(ch, "");
1022
+ }
1023
+ }
1024
+ const extra = escapeRegexChars(allowed);
1025
+ return new RegExp(`^[\\p{L}\\p{Nd}${extra}]+$`, "u");
1026
+ }
1027
+ var BusinessName = /* @__PURE__ */ createRule({
1028
+ name: "businessName",
1029
+ defaults: {},
1030
+ messages: {},
1031
+ build: (opts) => {
1032
+ const range = resolveRange(opts.length);
1033
+ const consecutiveRange = resolveRange(opts.consecutive);
1034
+ const boundary = resolveBoundary(opts.boundary);
1035
+ const base = opts.normalize !== false ? z3.string().trim() : z3.string();
1036
+ const minLen = range?.min;
1037
+ const maxLen = range?.max;
1038
+ const lbl = opts.label;
1039
+ const pattern = opts.regex ?? buildBusinessCharsetRegex(
1040
+ opts.extraChars,
1041
+ opts.disallowChars
1042
+ );
1043
+ const stage1 = base.superRefine((v, ctx) => {
1044
+ if (minLen !== void 0 && v.length < minLen) {
1045
+ ctx.addIssue({ code: "custom", params: { code: "min", namespace: "base", label: lbl, minimum: minLen } });
1046
+ return;
1047
+ }
1048
+ if (maxLen !== void 0 && v.length > maxLen) {
1049
+ ctx.addIssue({ code: "custom", params: { code: "max", namespace: "base", label: lbl, maximum: maxLen } });
1050
+ return;
1051
+ }
1052
+ if (!pattern.test(v)) {
1053
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "businessName", label: opts.label } });
1054
+ return;
1055
+ }
1056
+ if (boundary !== void 0 && !checkUnicodeBoundary(v, boundary)) {
1057
+ ctx.addIssue({ code: "custom", params: { code: "boundary", namespace: "businessName", label: opts.label } });
1058
+ }
1059
+ });
1060
+ let stage2 = z3.string();
1061
+ if (consecutiveRange?.max !== void 0) {
1062
+ stage2 = stage2.maxConsecutive({ max: consecutiveRange.max, namespace: "businessName", label: opts.label });
1063
+ }
1064
+ const validated = stage1.pipe(stage2);
1065
+ if (opts.titleCase === true) {
1066
+ return validated.transform(toTitleCase);
1067
+ }
1068
+ return validated;
1069
+ }
1070
+ });
1071
+
1072
+ // src/rules/color.ts
1073
+ import { z as z4 } from "zod";
1074
+ var HEX_ALPHA = /^#([0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
1075
+ var HEX_NO_ALPHA = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i;
1076
+ var RGB_ALPHA = /^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/;
1077
+ var RGB_NO_ALPHA = /^rgb\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*\)$/;
1078
+ var HSL_ALPHA = /^hsla?\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/;
1079
+ var HSL_NO_ALPHA = /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/;
1080
+ function getHexPattern(alpha) {
1081
+ return alpha ? HEX_ALPHA : HEX_NO_ALPHA;
1082
+ }
1083
+ function getRgbPattern(alpha) {
1084
+ return alpha ? RGB_ALPHA : RGB_NO_ALPHA;
1085
+ }
1086
+ function getHslPattern(alpha) {
1087
+ return alpha ? HSL_ALPHA : HSL_NO_ALPHA;
1088
+ }
1089
+ function matchesAnyFormat(value, alpha) {
1090
+ return getHexPattern(alpha).test(value) || getRgbPattern(alpha).test(value) || getHslPattern(alpha).test(value);
1091
+ }
1092
+ var Color = /* @__PURE__ */ createRule({
1093
+ name: "color",
1094
+ defaults: {},
1095
+ messages: {},
1096
+ build: (opts) => {
1097
+ const format = opts.format ?? "hex";
1098
+ const alpha = opts.alpha !== false;
1099
+ const base = opts.normalize !== false ? z4.string().transform((v) => v.trim().toLowerCase()) : z4.string();
1100
+ return base.pipe(
1101
+ z4.string().refine(
1102
+ (v) => {
1103
+ switch (format) {
1104
+ case "hex":
1105
+ return getHexPattern(alpha).test(v);
1106
+ case "rgb":
1107
+ return getRgbPattern(alpha).test(v);
1108
+ case "hsl":
1109
+ return getHslPattern(alpha).test(v);
1110
+ case "any":
1111
+ return matchesAnyFormat(v, alpha);
1112
+ /* v8 ignore start -- exhaustive default; format is constrained to hex|rgb|hsl|any by TypeScript */
1113
+ default:
1114
+ return false;
1115
+ }
1116
+ },
1117
+ { params: { code: "invalid", namespace: "color", label: opts.label } }
1118
+ )
1119
+ );
1120
+ }
1121
+ });
1122
+
1123
+ // src/rules/country.ts
1124
+ import { z as z5 } from "zod";
1125
+ async function resolveCountryCodes() {
1126
+ try {
1127
+ return getCountryCodes();
1128
+ } catch {
1129
+ return loadCountryCodes();
1130
+ }
1131
+ }
1132
+ function isValidCountryCode(value, format, codes) {
1133
+ if (format === "alpha2") {
1134
+ return codes.has(value);
1135
+ }
1136
+ for (const entry of codes.values()) {
1137
+ if (entry.alpha3 === value)
1138
+ return true;
1139
+ }
1140
+ return false;
1141
+ }
1142
+ var Country = /* @__PURE__ */ createRule({
1143
+ name: "country",
1144
+ defaults: {},
1145
+ messages: {},
1146
+ build: (opts) => {
1147
+ const format = opts.format ?? "alpha2";
1148
+ const allow = opts.allowCountries ?? [];
1149
+ const block = opts.blockCountries ?? [];
1150
+ let schema = opts.normalize !== false ? z5.string().transform((v) => v.trim().toUpperCase()) : z5.string();
1151
+ schema = schema.pipe(
1152
+ z5.string().refine(
1153
+ async (v) => {
1154
+ const codes = await resolveCountryCodes();
1155
+ return isValidCountryCode(v, format, codes);
1156
+ },
1157
+ { params: { code: "invalid", namespace: "country", label: opts.label } }
1158
+ )
1159
+ );
1160
+ if (allow.length > 0) {
1161
+ schema = schema.pipe(
1162
+ z5.string().superRefine((v, ctx) => {
1163
+ if (!allow.includes(v)) {
1164
+ ctx.addIssue({ code: "custom", params: { code: "notAllowed", namespace: "country", country: v, label: opts.label } });
1165
+ }
1166
+ })
1167
+ );
1168
+ }
1169
+ if (block.length > 0) {
1170
+ schema = schema.pipe(
1171
+ z5.string().superRefine((v, ctx) => {
1172
+ if (block.includes(v)) {
1173
+ ctx.addIssue({ code: "custom", params: { code: "blocked", namespace: "country", country: v, label: opts.label } });
1174
+ }
1175
+ })
1176
+ );
1177
+ }
1178
+ return schema;
1179
+ }
1180
+ });
1181
+
1182
+ // src/rules/creditCard.ts
1183
+ import { z as z6 } from "zod";
1184
+ var DIGITS_ONLY_RE = /^\d+$/;
1185
+ var STRIP_RE = /[\s-]/g;
1186
+ var MIN_LENGTH = 13;
1187
+ var MAX_LENGTH = 19;
1188
+ async function resolvePrefixes() {
1189
+ try {
1190
+ return getCreditCardPrefixes();
1191
+ } catch {
1192
+ return loadCreditCardPrefixes();
1193
+ }
1194
+ }
1195
+ function luhnCheck(digits) {
1196
+ let sum = 0;
1197
+ let alternate = false;
1198
+ for (let i = digits.length - 1; i >= 0; i--) {
1199
+ let n = Number(digits[i]);
1200
+ if (alternate) {
1201
+ n *= 2;
1202
+ if (n > 9)
1203
+ n -= 9;
1204
+ }
1205
+ sum += n;
1206
+ alternate = !alternate;
1207
+ }
1208
+ return sum % 10 === 0;
1209
+ }
1210
+ function matchPrefix(cardNumber, prefix) {
1211
+ if (prefix.includes("-")) {
1212
+ const parts = prefix.split("-");
1213
+ const low = parts[0];
1214
+ const high = parts[1];
1215
+ if (low === void 0 || high === void 0)
1216
+ return false;
1217
+ const cardPrefix = Number(cardNumber.slice(0, low.length));
1218
+ return cardPrefix >= Number(low) && cardPrefix <= Number(high);
1219
+ }
1220
+ return cardNumber.startsWith(prefix);
1221
+ }
1222
+ function detectIssuer(cardNumber, prefixes) {
1223
+ for (const [issuer, data] of prefixes) {
1224
+ for (const prefix of data.prefixes) {
1225
+ if (matchPrefix(cardNumber, prefix))
1226
+ return issuer;
1227
+ }
1228
+ }
1229
+ return void 0;
1230
+ }
1231
+ var CreditCard = /* @__PURE__ */ createRule({
1232
+ name: "creditCard",
1233
+ defaults: {},
1234
+ messages: {},
1235
+ build: (opts) => {
1236
+ const allow = opts.allowIssuers ?? [];
1237
+ const block = opts.blockIssuers ?? [];
1238
+ let schema = opts.normalize !== false ? z6.string().transform((v) => v.trim().replace(STRIP_RE, "")) : z6.string();
1239
+ schema = schema.pipe(
1240
+ z6.string().refine(
1241
+ (v) => {
1242
+ if (!DIGITS_ONLY_RE.test(v))
1243
+ return false;
1244
+ if (v.length < MIN_LENGTH || v.length > MAX_LENGTH)
1245
+ return false;
1246
+ return luhnCheck(v);
1247
+ },
1248
+ { params: { code: "invalid", namespace: "creditCard", label: opts.label } }
1249
+ )
1250
+ );
1251
+ if (allow.length > 0) {
1252
+ schema = schema.pipe(
1253
+ z6.string().superRefine(async (v, ctx) => {
1254
+ const prefixes = await resolvePrefixes();
1255
+ const issuer = detectIssuer(v, prefixes);
1256
+ if (issuer === void 0 || !allow.includes(issuer)) {
1257
+ ctx.addIssue({
1258
+ code: "custom",
1259
+ params: { code: "issuerNotAllowed", namespace: "creditCard", issuer: issuer ?? "unknown", label: opts.label }
1260
+ });
1261
+ }
1262
+ })
1263
+ );
1264
+ }
1265
+ if (block.length > 0) {
1266
+ schema = schema.pipe(
1267
+ z6.string().superRefine(async (v, ctx) => {
1268
+ const prefixes = await resolvePrefixes();
1269
+ const issuer = detectIssuer(v, prefixes);
1270
+ if (issuer !== void 0 && block.includes(issuer)) {
1271
+ ctx.addIssue({
1272
+ code: "custom",
1273
+ params: { code: "issuerBlocked", namespace: "creditCard", issuer, label: opts.label }
1274
+ });
1275
+ }
1276
+ })
1277
+ );
1278
+ }
1279
+ return schema;
1280
+ }
1281
+ });
1282
+
1283
+ // src/rules/currency.ts
1284
+ import { z as z7 } from "zod";
1285
+ async function resolveCurrencyCodes() {
1286
+ try {
1287
+ return getCurrencyCodes();
1288
+ } catch {
1289
+ return loadCurrencyCodes();
1290
+ }
1291
+ }
1292
+ var Currency = /* @__PURE__ */ createRule({
1293
+ name: "currency",
1294
+ defaults: {},
1295
+ messages: {},
1296
+ build: (opts) => {
1297
+ const allow = opts.allowCurrencies ?? [];
1298
+ const block = opts.blockCurrencies ?? [];
1299
+ let schema = opts.normalize !== false ? z7.string().transform((v) => v.trim().toUpperCase()) : z7.string();
1300
+ schema = schema.pipe(
1301
+ z7.string().refine(
1302
+ async (v) => {
1303
+ const codes = await resolveCurrencyCodes();
1304
+ return codes.has(v);
1305
+ },
1306
+ { params: { code: "invalid", namespace: "currency", label: opts.label } }
1307
+ )
1308
+ );
1309
+ if (allow.length > 0) {
1310
+ schema = schema.pipe(
1311
+ z7.string().superRefine((v, ctx) => {
1312
+ if (!allow.includes(v)) {
1313
+ ctx.addIssue({ code: "custom", params: { code: "notAllowed", namespace: "currency", currency: v, label: opts.label } });
1314
+ }
1315
+ })
1316
+ );
1317
+ }
1318
+ if (block.length > 0) {
1319
+ schema = schema.pipe(
1320
+ z7.string().superRefine((v, ctx) => {
1321
+ if (block.includes(v)) {
1322
+ ctx.addIssue({ code: "custom", params: { code: "blocked", namespace: "currency", currency: v, label: opts.label } });
1323
+ }
1324
+ })
1325
+ );
1326
+ }
1327
+ return schema;
1328
+ }
1329
+ });
1330
+
1331
+ // src/rules/dateTime.ts
1332
+ import { z as z8 } from "zod";
1333
+ var DATETIME_FORMAT_CHECK = z8.string().datetime();
1334
+ var DATE_FORMAT_CHECK = z8.string().date();
1335
+ var TIME_FORMAT_CHECK = z8.string().time();
1336
+ function parseToDate(value) {
1337
+ return value instanceof Date ? value : new Date(value);
1338
+ }
1339
+ function buildDateTimeSchema(opts) {
1340
+ const hasCustomOpts = opts.allowOffset !== void 0 || opts.allowLocal !== void 0 || opts.precision !== void 0;
1341
+ let check;
1342
+ if (hasCustomOpts) {
1343
+ const datetimeOpts = {};
1344
+ if (opts.allowOffset !== void 0)
1345
+ datetimeOpts.offset = opts.allowOffset;
1346
+ if (opts.allowLocal !== void 0)
1347
+ datetimeOpts.local = opts.allowLocal;
1348
+ if (opts.precision !== void 0)
1349
+ datetimeOpts.precision = opts.precision;
1350
+ check = z8.string().datetime(datetimeOpts);
1351
+ } else {
1352
+ check = DATETIME_FORMAT_CHECK;
1353
+ }
1354
+ const base = opts.normalize !== false ? z8.string().trim() : z8.string();
1355
+ return base.pipe(z8.string().superRefine((v, ctx) => {
1356
+ if (!check.safeParse(v).success) {
1357
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "dateTime", label: opts.label } });
1358
+ }
1359
+ }));
1360
+ }
1361
+ function buildDateSchema(opts) {
1362
+ const base = opts.normalize !== false ? z8.string().trim() : z8.string();
1363
+ return base.pipe(z8.string().superRefine((v, ctx) => {
1364
+ if (!DATE_FORMAT_CHECK.safeParse(v).success) {
1365
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "dateTime", label: opts.label } });
1366
+ }
1367
+ }));
1368
+ }
1369
+ function buildTimeSchema(opts) {
1370
+ const check = opts.precision !== void 0 ? z8.string().time({ precision: opts.precision }) : TIME_FORMAT_CHECK;
1371
+ const base = opts.normalize !== false ? z8.string().trim() : z8.string();
1372
+ return base.pipe(z8.string().superRefine((v, ctx) => {
1373
+ if (!check.safeParse(v).success) {
1374
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "dateTime", label: opts.label } });
1375
+ }
1376
+ }));
1377
+ }
1378
+ function applyRangeRefinements(schema, opts) {
1379
+ let result = schema;
1380
+ if (opts.min !== void 0) {
1381
+ const minDate = parseToDate(opts.min);
1382
+ result = result.refine(
1383
+ // SAFETY: refine callback on z.string() schema; v is always a string
1384
+ (v) => new Date(v) >= minDate,
1385
+ { params: { code: "tooEarly", namespace: "dateTime", minimum: minDate.toISOString(), label: opts.label } }
1386
+ );
1387
+ }
1388
+ if (opts.max !== void 0) {
1389
+ const maxDate = parseToDate(opts.max);
1390
+ result = result.refine(
1391
+ // SAFETY: refine callback on z.string() schema; v is always a string
1392
+ (v) => new Date(v) <= maxDate,
1393
+ { params: { code: "tooLate", namespace: "dateTime", maximum: maxDate.toISOString(), label: opts.label } }
1394
+ );
1395
+ }
1396
+ if (opts.allowFuture === false) {
1397
+ result = result.refine(
1398
+ // SAFETY: refine callback on z.string() schema; v is always a string
1399
+ (v) => new Date(v) <= /* @__PURE__ */ new Date(),
1400
+ { params: { code: "noFuture", namespace: "dateTime", label: opts.label } }
1401
+ );
1402
+ }
1403
+ if (opts.allowPast === false) {
1404
+ result = result.refine(
1405
+ // SAFETY: refine callback on z.string() schema; v is always a string
1406
+ (v) => new Date(v) >= /* @__PURE__ */ new Date(),
1407
+ { params: { code: "noPast", namespace: "dateTime", label: opts.label } }
1408
+ );
1409
+ }
1410
+ return result;
1411
+ }
1412
+ var DateTime = /* @__PURE__ */ createRule({
1413
+ name: "dateTime",
1414
+ defaults: {},
1415
+ messages: {},
1416
+ build: (opts) => {
1417
+ let schema;
1418
+ switch (opts.format) {
1419
+ case "date":
1420
+ schema = buildDateSchema(opts);
1421
+ break;
1422
+ case "time":
1423
+ schema = buildTimeSchema(opts);
1424
+ break;
1425
+ case "iso":
1426
+ case void 0:
1427
+ schema = buildDateTimeSchema(opts);
1428
+ break;
1429
+ }
1430
+ if (opts.format !== "time") {
1431
+ schema = applyRangeRefinements(schema, opts);
1432
+ }
1433
+ return schema;
1434
+ }
1435
+ });
1436
+
1437
+ // src/rules/email.ts
1438
+ import { z as z9 } from "zod";
1439
+
1440
+ // src/internal/domainMatch.ts
1441
+ function matchesDomainList(hostname, domains) {
1442
+ return domains.some(
1443
+ (d) => hostname === d || hostname.endsWith(`.${d}`)
1444
+ );
1445
+ }
1446
+
1447
+ // src/internal/lengthCheck.ts
1448
+ function applyLengthCheck(value, min, max, label, ctx) {
1449
+ if (min !== void 0 && value.length < min) {
1450
+ ctx.addIssue({ code: "custom", params: { code: "min", namespace: "base", label, minimum: min } });
1451
+ }
1452
+ if (max !== void 0 && value.length > max) {
1453
+ ctx.addIssue({ code: "custom", params: { code: "max", namespace: "base", label, maximum: max } });
1454
+ }
1455
+ }
1456
+
1457
+ // src/rules/email.ts
1458
+ function extractDomain(email) {
1459
+ return email.split("@")[1] ?? "";
1460
+ }
1461
+ function extractLocalPart(email) {
1462
+ return email.split("@")[0] ?? "";
1463
+ }
1464
+ var EMAIL_FORMAT_CHECK = z9.string().email();
1465
+ var Email = /* @__PURE__ */ createRule({
1466
+ name: "email",
1467
+ defaults: {},
1468
+ messages: {},
1469
+ build: (opts) => {
1470
+ const range = resolveRange(opts.length);
1471
+ const maxLen = range?.max ?? 254;
1472
+ const minLen = range?.min;
1473
+ const ns = "email";
1474
+ const lbl = opts.label;
1475
+ const base = opts.normalize !== false ? z9.string().trim().toLowerCase() : z9.string();
1476
+ let schema = base.pipe(z9.string().superRefine((v, ctx) => {
1477
+ if (!EMAIL_FORMAT_CHECK.safeParse(v).success) {
1478
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: ns, label: lbl } });
1479
+ return;
1480
+ }
1481
+ applyLengthCheck(v, minLen, maxLen, lbl, ctx);
1482
+ }));
1483
+ schema = applyBusinessRules(schema, opts);
1484
+ return schema;
1485
+ }
1486
+ });
1487
+ function applyBusinessRules(schema, opts) {
1488
+ let result = schema;
1489
+ if (opts.blockPlusAlias === true) {
1490
+ result = result.pipe(z9.string().refine(
1491
+ (v) => !extractLocalPart(v).includes("+"),
1492
+ { params: { code: "plusAliasBlocked", namespace: "email", label: opts.label } }
1493
+ ));
1494
+ }
1495
+ result = applyDomainFilters(result, opts);
1496
+ if (opts.allowSubdomains === false) {
1497
+ result = result.pipe(z9.string().refine(
1498
+ (v) => extractDomain(v).split(".").length <= 2,
1499
+ { params: { code: "subdomainNotAllowed", namespace: "email", label: opts.label } }
1500
+ ));
1501
+ }
1502
+ if (opts.blockDisposable === true) {
1503
+ result = applyDisposableCheck(result, opts.label);
1504
+ }
1505
+ return result;
1506
+ }
1507
+ function applyDomainFilters(schema, opts) {
1508
+ let result = schema;
1509
+ const allow = opts.allowDomains ?? [];
1510
+ const block = opts.blockDomains ?? [];
1511
+ if (allow.length > 0) {
1512
+ result = result.pipe(z9.string().superRefine((v, ctx) => {
1513
+ if (!matchesDomainList(extractDomain(v), allow)) {
1514
+ ctx.addIssue({ code: "custom", params: { code: "domainNotAllowed", namespace: "email", domain: extractDomain(v), label: opts.label } });
1515
+ }
1516
+ }));
1517
+ }
1518
+ if (block.length > 0) {
1519
+ result = result.pipe(z9.string().superRefine((v, ctx) => {
1520
+ if (matchesDomainList(extractDomain(v), block)) {
1521
+ ctx.addIssue({ code: "custom", params: { code: "domainBlocked", namespace: "email", domain: extractDomain(v), label: opts.label } });
1522
+ }
1523
+ }));
1524
+ }
1525
+ return result;
1526
+ }
1527
+ function applyDisposableCheck(schema, label) {
1528
+ return schema.pipe(z9.string().refine(
1529
+ async (value) => {
1530
+ const domain = extractDomain(value);
1531
+ try {
1532
+ const preloaded = getDisposableDomains();
1533
+ return !preloaded.has(domain);
1534
+ } catch {
1535
+ try {
1536
+ const { isDisposableEmailDomain } = await import("disposable-email-domains-js");
1537
+ return !isDisposableEmailDomain(domain);
1538
+ } catch {
1539
+ return true;
1540
+ }
1541
+ }
1542
+ },
1543
+ { params: { code: "disposableBlocked", namespace: "email", label } }
1544
+ ));
1545
+ }
1546
+
1547
+ // src/rules/iban.ts
1548
+ import { z as z10 } from "zod";
1549
+ var IBAN_STRUCTURE_RE = /^[A-Z]{2}\d{2}[A-Z0-9]+$/;
1550
+ var STRIP_SPACES_RE = /\s/g;
1551
+ async function resolvePatterns() {
1552
+ try {
1553
+ return getIbanPatterns();
1554
+ } catch {
1555
+ return loadIbanPatterns();
1556
+ }
1557
+ }
1558
+ function mod97(ibanDigits) {
1559
+ let remainder = 0;
1560
+ for (const char of ibanDigits) {
1561
+ remainder = (remainder * 10 + Number(char)) % 97;
1562
+ }
1563
+ return remainder;
1564
+ }
1565
+ function validateMod97(iban) {
1566
+ const rearranged = iban.slice(4) + iban.slice(0, 4);
1567
+ let digits = "";
1568
+ for (const char of rearranged) {
1569
+ if (char >= "A" && char <= "Z") {
1570
+ digits += String(char.charCodeAt(0) - 55);
1571
+ } else {
1572
+ digits += char;
1573
+ }
1574
+ }
1575
+ return mod97(digits) === 1;
1576
+ }
1577
+ var Iban = /* @__PURE__ */ createRule({
1578
+ name: "iban",
1579
+ defaults: {},
1580
+ messages: {},
1581
+ build: (opts) => {
1582
+ const allow = opts.allowCountries ?? [];
1583
+ const block = opts.blockCountries ?? [];
1584
+ let schema = opts.normalize !== false ? z10.string().transform(
1585
+ (v) => v.trim().toUpperCase().replace(STRIP_SPACES_RE, "")
1586
+ ) : z10.string();
1587
+ schema = schema.pipe(
1588
+ z10.string().refine(
1589
+ async (v) => {
1590
+ if (!IBAN_STRUCTURE_RE.test(v))
1591
+ return false;
1592
+ const country = v.slice(0, 2);
1593
+ const patterns = await resolvePatterns();
1594
+ const pattern = patterns.get(country);
1595
+ if (pattern === void 0)
1596
+ return false;
1597
+ if (v.length !== pattern.length)
1598
+ return false;
1599
+ if (!pattern.regex.test(v))
1600
+ return false;
1601
+ return validateMod97(v);
1602
+ },
1603
+ { params: { code: "invalid", namespace: "iban", label: opts.label } }
1604
+ )
1605
+ );
1606
+ if (allow.length > 0) {
1607
+ schema = schema.pipe(
1608
+ z10.string().superRefine((v, ctx) => {
1609
+ if (!allow.includes(v.slice(0, 2))) {
1610
+ ctx.addIssue({ code: "custom", params: { code: "countryNotAllowed", namespace: "iban", country: v.slice(0, 2), label: opts.label } });
1611
+ }
1612
+ })
1613
+ );
1614
+ }
1615
+ if (block.length > 0) {
1616
+ schema = schema.pipe(
1617
+ z10.string().superRefine((v, ctx) => {
1618
+ if (block.includes(v.slice(0, 2))) {
1619
+ ctx.addIssue({ code: "custom", params: { code: "countryBlocked", namespace: "iban", country: v.slice(0, 2), label: opts.label } });
1620
+ }
1621
+ })
1622
+ );
1623
+ }
1624
+ return schema;
1625
+ }
1626
+ });
1627
+
1628
+ // src/rules/ipAddress.ts
1629
+ import { z as z11 } from "zod";
1630
+ function isPrivateIpv4(ip) {
1631
+ const parts = ip.split(".").map(Number);
1632
+ const first = parts[0] ?? -1;
1633
+ const second = parts[1] ?? -1;
1634
+ if (first === 10)
1635
+ return true;
1636
+ if (first === 172 && second >= 16 && second <= 31)
1637
+ return true;
1638
+ if (first === 192 && second === 168)
1639
+ return true;
1640
+ if (first === 127)
1641
+ return true;
1642
+ if (first === 0)
1643
+ return true;
1644
+ return false;
1645
+ }
1646
+ function isPrivateIpv6(ip) {
1647
+ const lower = ip.toLowerCase();
1648
+ if (lower === "::1")
1649
+ return true;
1650
+ if (lower.startsWith("fc") || lower.startsWith("fd"))
1651
+ return true;
1652
+ if (lower.startsWith("fe80"))
1653
+ return true;
1654
+ if (lower === "::")
1655
+ return true;
1656
+ return false;
1657
+ }
1658
+ function stripCidr(ip) {
1659
+ const slashIndex = ip.indexOf("/");
1660
+ return slashIndex === -1 ? ip : ip.slice(0, slashIndex);
1661
+ }
1662
+ var IPV4_CHECK = z11.string().ipv4();
1663
+ var IPV6_CHECK = z11.string().ipv6();
1664
+ var CIDRV4_CHECK = z11.string().cidrv4();
1665
+ var CIDRV6_CHECK = z11.string().cidrv6();
1666
+ function buildV4Schema(allowCidr, normalize, label) {
1667
+ const base = normalize ? z11.string().trim() : z11.string();
1668
+ const check = allowCidr ? CIDRV4_CHECK : IPV4_CHECK;
1669
+ return base.superRefine((v, ctx) => {
1670
+ if (!check.safeParse(v).success) {
1671
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "ipAddress", label } });
1672
+ }
1673
+ });
1674
+ }
1675
+ function buildV6Schema(allowCidr, normalize, label) {
1676
+ const base = normalize ? z11.string().trim() : z11.string();
1677
+ const check = allowCidr ? CIDRV6_CHECK : IPV6_CHECK;
1678
+ return base.superRefine((v, ctx) => {
1679
+ if (!check.safeParse(v).success) {
1680
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "ipAddress", label } });
1681
+ }
1682
+ });
1683
+ }
1684
+ function buildAnyVersionSchema(allowCidr, normalize, label) {
1685
+ const v4Check = allowCidr ? CIDRV4_CHECK : IPV4_CHECK;
1686
+ const v6Check = allowCidr ? CIDRV6_CHECK : IPV6_CHECK;
1687
+ const base = normalize ? z11.string().trim() : z11.string();
1688
+ return base.superRefine((v, ctx) => {
1689
+ if (!v4Check.safeParse(v).success && !v6Check.safeParse(v).success) {
1690
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "ipAddress", label } });
1691
+ }
1692
+ });
1693
+ }
1694
+ function applyPrivateRefinement(schema, version, label) {
1695
+ return schema.refine(
1696
+ (v) => {
1697
+ const bare = stripCidr(v);
1698
+ if (version === "v4")
1699
+ return !isPrivateIpv4(bare);
1700
+ if (version === "v6")
1701
+ return !isPrivateIpv6(bare);
1702
+ return bare.includes(":") ? !isPrivateIpv6(bare) : !isPrivateIpv4(bare);
1703
+ },
1704
+ { params: { code: "privateNotAllowed", namespace: "ipAddress", label } }
1705
+ );
1706
+ }
1707
+ var IpAddress = /* @__PURE__ */ createRule({
1708
+ name: "ipAddress",
1709
+ defaults: {},
1710
+ messages: {},
1711
+ build: (opts) => {
1712
+ const version = opts.version ?? "any";
1713
+ const allowCidr = opts.allowCidr === true;
1714
+ const normalize = opts.normalize !== false;
1715
+ let schema;
1716
+ switch (version) {
1717
+ case "v4":
1718
+ schema = buildV4Schema(allowCidr, normalize, opts.label);
1719
+ break;
1720
+ case "v6":
1721
+ schema = buildV6Schema(allowCidr, normalize, opts.label);
1722
+ break;
1723
+ case "any":
1724
+ schema = buildAnyVersionSchema(allowCidr, normalize, opts.label);
1725
+ break;
1726
+ }
1727
+ if (opts.allowPrivate === false) {
1728
+ schema = applyPrivateRefinement(schema, version, opts.label);
1729
+ }
1730
+ return schema;
1731
+ }
1732
+ });
1733
+
1734
+ // src/rules/jwt.ts
1735
+ import { z as z12 } from "zod";
1736
+ var BASE64URL_HYPHEN_RE = /-/g;
1737
+ var BASE64URL_UNDERSCORE_RE = /_/g;
1738
+ function base64UrlDecode(str) {
1739
+ let base64 = str.replace(BASE64URL_HYPHEN_RE, "+").replace(BASE64URL_UNDERSCORE_RE, "/");
1740
+ const padding = base64.length % 4;
1741
+ if (padding === 2)
1742
+ base64 += "==";
1743
+ else if (padding === 3)
1744
+ base64 += "=";
1745
+ return atob(base64);
1746
+ }
1747
+ function decodeJwtParts(value) {
1748
+ const segments = value.split(".");
1749
+ if (segments.length !== 3)
1750
+ return null;
1751
+ try {
1752
+ const headerStr = segments[0] ?? "";
1753
+ const payloadStr = segments[1] ?? "";
1754
+ const header = JSON.parse(base64UrlDecode(headerStr));
1755
+ const payload = JSON.parse(base64UrlDecode(payloadStr));
1756
+ return { header, payload };
1757
+ } catch {
1758
+ return null;
1759
+ }
1760
+ }
1761
+ function isExpired(payload, tolerance) {
1762
+ const exp = payload["exp"];
1763
+ if (typeof exp !== "number")
1764
+ return true;
1765
+ const now = Math.floor(Date.now() / 1e3);
1766
+ return exp <= now - tolerance;
1767
+ }
1768
+ function isNotYetValid(payload, tolerance) {
1769
+ const nbf = payload["nbf"];
1770
+ if (typeof nbf !== "number")
1771
+ return false;
1772
+ const now = Math.floor(Date.now() / 1e3);
1773
+ return nbf > now + tolerance;
1774
+ }
1775
+ function validateAlgorithm(header, algorithms, ctx, label) {
1776
+ const alg = header["alg"];
1777
+ if (typeof alg !== "string" || !algorithms.includes(alg)) {
1778
+ ctx.addIssue({
1779
+ code: "custom",
1780
+ params: {
1781
+ code: "algorithmNotAllowed",
1782
+ namespace: "jwt",
1783
+ algorithm: String(alg ?? "unknown"),
1784
+ label
1785
+ }
1786
+ });
1787
+ }
1788
+ }
1789
+ function validateClaims(payload, claims, ctx, label) {
1790
+ for (const claim of claims) {
1791
+ if (payload[claim] === void 0) {
1792
+ ctx.addIssue({
1793
+ code: "custom",
1794
+ params: { code: "missingClaim", namespace: "jwt", claim, label }
1795
+ });
1796
+ }
1797
+ }
1798
+ }
1799
+ function validateTemporal(payload, opts, ctx) {
1800
+ const tolerance = opts.clockTolerance ?? 0;
1801
+ if (opts.requireExpiry === true && payload["exp"] === void 0) {
1802
+ ctx.addIssue({
1803
+ code: "custom",
1804
+ params: { code: "expiryRequired", namespace: "jwt", label: opts.label }
1805
+ });
1806
+ }
1807
+ if (opts.checkExpiry === true && isExpired(payload, tolerance)) {
1808
+ ctx.addIssue({
1809
+ code: "custom",
1810
+ params: { code: "expired", namespace: "jwt", label: opts.label }
1811
+ });
1812
+ }
1813
+ if (opts.checkNotBefore === true && isNotYetValid(payload, tolerance)) {
1814
+ ctx.addIssue({
1815
+ code: "custom",
1816
+ params: { code: "notYetValid", namespace: "jwt", label: opts.label }
1817
+ });
1818
+ }
1819
+ }
1820
+ var Jwt = /* @__PURE__ */ createRule({
1821
+ name: "jwt",
1822
+ defaults: {},
1823
+ messages: {},
1824
+ build: (opts) => {
1825
+ const schema = opts.normalize !== false ? z12.string().trim() : z12.string();
1826
+ return schema.superRefine((value, ctx) => {
1827
+ const parts = decodeJwtParts(value);
1828
+ if (!parts) {
1829
+ ctx.addIssue({
1830
+ code: "custom",
1831
+ params: { code: "invalid", namespace: "jwt", label: opts.label }
1832
+ });
1833
+ return;
1834
+ }
1835
+ const { header, payload } = parts;
1836
+ if (opts.allowAlgorithms && opts.allowAlgorithms.length > 0) {
1837
+ validateAlgorithm(header, opts.allowAlgorithms, ctx, opts.label);
1838
+ }
1839
+ validateTemporal(payload, opts, ctx);
1840
+ if (opts.requireClaims && opts.requireClaims.length > 0) {
1841
+ validateClaims(payload, opts.requireClaims, ctx, opts.label);
1842
+ }
1843
+ });
1844
+ }
1845
+ });
1846
+
1847
+ // src/rules/licenseKey.ts
1848
+ import { z as z13 } from "zod";
1849
+ var CHARSET_MAP = {
1850
+ alphanumeric: "A-Z0-9",
1851
+ alpha: "A-Z",
1852
+ numeric: "0-9",
1853
+ hex: "0-9A-F"
1854
+ };
1855
+ function buildLicenseKeyPattern(segments, segmentLength, separator, charset) {
1856
+ const charClass = CHARSET_MAP[charset] ?? CHARSET_MAP["alphanumeric"];
1857
+ const sep = escapeRegexChars(separator);
1858
+ const segPart = `[${charClass}]{${segmentLength}}`;
1859
+ const repeatPart = segments > 1 ? `(${sep}${segPart}){${segments - 1}}` : "";
1860
+ return new RegExp(`^${segPart}${repeatPart}$`);
1861
+ }
1862
+ var UUID_FORMAT_CHECK = z13.string().uuid();
1863
+ var LicenseKey = /* @__PURE__ */ createRule({
1864
+ name: "licenseKey",
1865
+ defaults: {},
1866
+ messages: {},
1867
+ build: (opts) => {
1868
+ if (opts.type === "uuid") {
1869
+ const uuidBase = opts.normalize !== false ? z13.string().trim().toUpperCase() : z13.string();
1870
+ return uuidBase.pipe(z13.string().superRefine((v, ctx) => {
1871
+ if (!UUID_FORMAT_CHECK.safeParse(v.toLowerCase()).success) {
1872
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "licenseKey", label: opts.label } });
1873
+ }
1874
+ }));
1875
+ }
1876
+ const base = opts.normalize !== false ? z13.string().transform((v) => v.trim().toUpperCase()).pipe(z13.string()) : z13.string();
1877
+ const pattern = opts.regex ?? buildLicenseKeyPattern(
1878
+ opts.segments ?? 5,
1879
+ opts.segmentLength ?? 5,
1880
+ opts.separator ?? "-",
1881
+ opts.charset ?? "alphanumeric"
1882
+ );
1883
+ return base.refine(
1884
+ (v) => pattern.test(v),
1885
+ { params: { code: "invalid", namespace: "licenseKey", label: opts.label } }
1886
+ );
1887
+ }
1888
+ });
1889
+
1890
+ // src/rules/macAddress.ts
1891
+ import { z as z14 } from "zod";
1892
+ var COLON_PATTERN = /^[\dA-F]{2}(:[\dA-F]{2}){5}$/i;
1893
+ var HYPHEN_PATTERN = /^[\dA-F]{2}(-[\dA-F]{2}){5}$/i;
1894
+ var BARE_PATTERN = /^[\dA-F]{12}$/i;
1895
+ var PATTERNS = {
1896
+ ":": COLON_PATTERN,
1897
+ "-": HYPHEN_PATTERN,
1898
+ "none": BARE_PATTERN
1899
+ };
1900
+ function getPattern(delimiter) {
1901
+ return PATTERNS[delimiter] ?? COLON_PATTERN;
1902
+ }
1903
+ var MacAddress = /* @__PURE__ */ createRule({
1904
+ name: "macAddress",
1905
+ defaults: {},
1906
+ messages: {},
1907
+ build: (opts) => {
1908
+ const delimiter = opts.delimiter ?? ":";
1909
+ const pattern = getPattern(delimiter);
1910
+ const base = opts.normalize !== false ? z14.string().trim() : z14.string();
1911
+ return base.refine(
1912
+ (v) => pattern.test(v),
1913
+ { params: { code: "invalid", namespace: "macAddress", label: opts.label } }
1914
+ );
1915
+ }
1916
+ });
1917
+
1918
+ // src/rules/password.ts
1919
+ import { z as z15 } from "zod";
1920
+ function applyLength(schema, range, label) {
1921
+ if (range === void 0)
1922
+ return schema;
1923
+ const min = range.min;
1924
+ const max = range.max;
1925
+ return schema.superRefine((v, ctx) => {
1926
+ applyLengthCheck(v, min, max, label, ctx);
1927
+ });
1928
+ }
1929
+ function applyBlockCommon(schema, blockCommon, label) {
1930
+ const tier = blockCommon === true || blockCommon === "basic" ? "basic" : blockCommon;
1931
+ return schema.refine(
1932
+ async (v) => {
1933
+ if (typeof v !== "string")
1934
+ return true;
1935
+ try {
1936
+ const passwords = getCommonPasswords(tier);
1937
+ return !passwords.has(v.toLowerCase());
1938
+ } catch {
1939
+ const passwords = await loadCommonPasswords(tier);
1940
+ return !passwords.has(v.toLowerCase());
1941
+ }
1942
+ },
1943
+ { params: { code: "commonBlocked", namespace: "password", label } }
1944
+ );
1945
+ }
1946
+ var Password = /* @__PURE__ */ createRule({
1947
+ name: "password",
1948
+ defaults: {},
1949
+ messages: {},
1950
+ build: (opts) => {
1951
+ const ns = "password";
1952
+ let base = z15.string();
1953
+ if (opts.normalize !== false) {
1954
+ base = base.trim();
1955
+ }
1956
+ let schema = applyLength(base, resolveRange(opts.length), opts.label);
1957
+ const upper = resolveRange(opts.uppercase);
1958
+ const lower = resolveRange(opts.lowercase);
1959
+ const digit = resolveRange(opts.digits);
1960
+ const special = resolveRange(opts.special);
1961
+ const consec = resolveRange(opts.consecutive);
1962
+ const lbl = opts.label;
1963
+ if (upper !== void 0 && (upper.min !== void 0 && upper.min > 0 || upper.max !== void 0)) {
1964
+ schema = schema.hasUppercase({ min: upper.min ?? 0, max: upper.max, namespace: ns, label: lbl });
1965
+ }
1966
+ if (lower !== void 0 && (lower.min !== void 0 && lower.min > 0 || lower.max !== void 0)) {
1967
+ schema = schema.hasLowercase({ min: lower.min ?? 0, max: lower.max, namespace: ns, label: lbl });
1968
+ }
1969
+ if (digit !== void 0 && (digit.min !== void 0 && digit.min > 0 || digit.max !== void 0)) {
1970
+ schema = schema.hasDigits({ min: digit.min ?? 0, max: digit.max, namespace: ns, label: lbl });
1971
+ }
1972
+ if (special !== void 0 && (special.min !== void 0 && special.min > 0 || special.max !== void 0)) {
1973
+ schema = schema.hasSpecial({ min: special.min ?? 0, max: special.max, namespace: ns, label: lbl });
1974
+ }
1975
+ if (consec?.max !== void 0) {
1976
+ schema = schema.maxConsecutive({ max: consec.max, namespace: ns, label: lbl });
1977
+ }
1978
+ if (opts.blockCommon !== false && opts.blockCommon !== void 0) {
1979
+ schema = applyBlockCommon(schema, opts.blockCommon, opts.label);
1980
+ }
1981
+ return schema;
1982
+ }
1983
+ });
1984
+
1985
+ // src/rules/passwordConfirmation.ts
1986
+ var PasswordConfirmation = /* @__PURE__ */ (() => {
1987
+ return (options) => {
1988
+ initAugmentation();
1989
+ const tier1 = RULE_DEFAULTS["passwordConfirmation"] ?? {};
1990
+ const tier2 = getConfig2().rules?.passwordConfirmation ?? {};
1991
+ const merged = mergeThreeTiers(
1992
+ tier1,
1993
+ tier2,
1994
+ options ?? {}
1995
+ );
1996
+ const passthrough = {};
1997
+ if (merged.label !== void 0)
1998
+ passthrough["label"] = merged.label;
1999
+ if (merged.emptyToUndefined !== void 0)
2000
+ passthrough["emptyToUndefined"] = merged.emptyToUndefined;
2001
+ if (merged.normalize !== void 0)
2002
+ passthrough["normalize"] = merged.normalize;
2003
+ if (merged.customFn !== void 0)
2004
+ passthrough["customFn"] = merged.customFn;
2005
+ const schema = Password(passthrough);
2006
+ registerCrossField(schema, {
2007
+ sameAs: merged.passwordField ?? "password",
2008
+ label: merged.label
2009
+ });
2010
+ return schema;
2011
+ };
2012
+ })();
2013
+
2014
+ // src/rules/personName.ts
2015
+ import { z as z16 } from "zod";
2016
+ var DEFAULT_EXTRA2 = " -'\u2019";
2017
+ function buildCharsetRegex(allowUnicode, extraChars, disallowChars) {
2018
+ let allowed = DEFAULT_EXTRA2;
2019
+ if (extraChars !== void 0) {
2020
+ allowed += extraChars;
2021
+ }
2022
+ if (disallowChars !== void 0) {
2023
+ for (const ch of disallowChars) {
2024
+ allowed = allowed.replaceAll(ch, "");
2025
+ }
2026
+ }
2027
+ const letterClass = allowUnicode ? "\\p{L}" : "a-zA-Z";
2028
+ const extra = escapeRegexChars(allowed);
2029
+ return new RegExp(`^[${letterClass}${extra}]+$`, "u");
2030
+ }
2031
+ var PersonName = /* @__PURE__ */ createRule({
2032
+ name: "personName",
2033
+ defaults: {},
2034
+ messages: {},
2035
+ build: (opts) => {
2036
+ const range = resolveRange(opts.length);
2037
+ const wordsRange = resolveRange(opts.words);
2038
+ const consecutiveRange = resolveRange(opts.consecutive);
2039
+ const boundary = resolveBoundary(opts.boundary);
2040
+ const base = opts.normalize !== false ? z16.string().trim() : z16.string();
2041
+ const minLen = range?.min;
2042
+ const maxLen = range?.max;
2043
+ const lbl = opts.label;
2044
+ const pattern = opts.regex ?? buildCharsetRegex(
2045
+ opts.allowUnicode !== false,
2046
+ opts.extraChars,
2047
+ opts.disallowChars
2048
+ );
2049
+ const stage1 = base.superRefine((v, ctx) => {
2050
+ if (minLen !== void 0 && v.length < minLen) {
2051
+ ctx.addIssue({ code: "custom", params: { code: "min", namespace: "base", label: lbl, minimum: minLen } });
2052
+ return;
2053
+ }
2054
+ if (maxLen !== void 0 && v.length > maxLen) {
2055
+ ctx.addIssue({ code: "custom", params: { code: "max", namespace: "base", label: lbl, maximum: maxLen } });
2056
+ return;
2057
+ }
2058
+ if (!pattern.test(v)) {
2059
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "personName", label: lbl } });
2060
+ return;
2061
+ }
2062
+ if (boundary !== void 0 && !checkUnicodeBoundary(v, boundary)) {
2063
+ ctx.addIssue({ code: "custom", params: { code: "boundary", namespace: "personName", label: lbl } });
2064
+ }
2065
+ });
2066
+ let stage2 = z16.string();
2067
+ if (consecutiveRange?.max !== void 0) {
2068
+ stage2 = stage2.maxConsecutive({ max: consecutiveRange.max, namespace: "personName", label: lbl });
2069
+ }
2070
+ if (wordsRange?.max !== void 0) {
2071
+ stage2 = stage2.maxWords({ max: wordsRange.max, namespace: "personName", label: lbl });
2072
+ }
2073
+ const validated = stage1.pipe(stage2);
2074
+ if (opts.titleCase === true) {
2075
+ return validated.transform(toTitleCase);
2076
+ }
2077
+ return validated;
2078
+ }
2079
+ });
2080
+
2081
+ // src/rules/phone.ts
2082
+ import { z as z17 } from "zod";
2083
+ function formatPhoneNumber(parsed, fmt) {
2084
+ switch (fmt) {
2085
+ case "e164":
2086
+ return parsed.format("E.164");
2087
+ case "international":
2088
+ return parsed.format("INTERNATIONAL");
2089
+ case "national":
2090
+ return parsed.format("NATIONAL");
2091
+ }
2092
+ }
2093
+ function tryParsePhone(value, country, parser) {
2094
+ try {
2095
+ return parser(value, country);
2096
+ } catch {
2097
+ return null;
2098
+ }
2099
+ }
2100
+ function addPhoneIssue(ctx, code, label, extras) {
2101
+ ctx.addIssue({
2102
+ code: "custom",
2103
+ params: { code, namespace: "phone", label, ...extras }
2104
+ });
2105
+ }
2106
+ function validatePhoneConstraints(parsed, opts, ctx) {
2107
+ const lbl = opts.label;
2108
+ if (opts.requireMobile) {
2109
+ const phoneType = parsed.getType();
2110
+ if (phoneType !== "MOBILE" && phoneType !== "FIXED_LINE_OR_MOBILE") {
2111
+ addPhoneIssue(ctx, "requireMobile", lbl);
2112
+ return;
2113
+ }
2114
+ }
2115
+ const parsedCountry = parsed.country;
2116
+ const allow = opts.allowCountries ?? [];
2117
+ const block = opts.blockCountries ?? [];
2118
+ if (allow.length > 0 && (!parsedCountry || !allow.includes(parsedCountry))) {
2119
+ addPhoneIssue(ctx, "countryNotAllowed", lbl, { country: parsedCountry ?? "unknown" });
2120
+ return;
2121
+ }
2122
+ if (block.length > 0 && parsedCountry && block.includes(parsedCountry)) {
2123
+ addPhoneIssue(ctx, "countryBlocked", lbl, { country: parsedCountry });
2124
+ }
2125
+ }
2126
+ var Phone = /* @__PURE__ */ createRule({
2127
+ name: "phone",
2128
+ defaults: {},
2129
+ messages: {},
2130
+ build: (opts) => {
2131
+ const metadata = opts.metadata;
2132
+ if (opts.requireMobile && metadata === "min") {
2133
+ throw new Error(
2134
+ 'validex: requireMobile: true requires metadata: "mobile" or "max". Min metadata cannot detect mobile numbers reliably.'
2135
+ );
2136
+ }
2137
+ if (metadata === "custom" && (opts.customMetadataPath === void 0 || opts.customMetadataPath === "")) {
2138
+ throw new Error('validex: Phone metadata "custom" requires customMetadataPath');
2139
+ }
2140
+ const fmt = opts.format ?? "e164";
2141
+ const base = opts.normalize !== false ? z17.string().trim() : z17.string();
2142
+ let cachedParsed;
2143
+ return base.superRefine(
2144
+ async (value, ctx) => {
2145
+ cachedParsed = void 0;
2146
+ if (opts.requireCountryCode && !value.startsWith("+")) {
2147
+ addPhoneIssue(ctx, "countryCodeRequired", opts.label);
2148
+ return;
2149
+ }
2150
+ const parser = await loadPhoneParser(metadata, opts.customMetadataPath);
2151
+ const parsed = tryParsePhone(value, opts.country, parser);
2152
+ if (!parsed || !parsed.isValid()) {
2153
+ addPhoneIssue(ctx, "invalid", opts.label);
2154
+ return;
2155
+ }
2156
+ cachedParsed = parsed;
2157
+ validatePhoneConstraints(parsed, opts, ctx);
2158
+ }
2159
+ ).transform(async (value) => {
2160
+ if (opts.normalize === false)
2161
+ return value;
2162
+ if (cachedParsed === void 0)
2163
+ return value;
2164
+ return formatPhoneNumber(cachedParsed, fmt);
2165
+ });
2166
+ }
2167
+ });
2168
+
2169
+ // src/rules/postalCode.ts
2170
+ import { z as z18 } from "zod";
2171
+ var PostalCode = /* @__PURE__ */ createRule({
2172
+ name: "postalCode",
2173
+ defaults: {},
2174
+ messages: {},
2175
+ build: (opts) => {
2176
+ const country = opts.country.toUpperCase();
2177
+ const mod = getPostalCodes();
2178
+ if (mod !== void 0 && !opts.regex && !opts.customFn && !mod.postcodeValidatorExistsForCountry(country)) {
2179
+ throw new Error(
2180
+ `validex: PostalCode country "${opts.country}" is not supported. Provide a regex or customFn for custom validation.`
2181
+ );
2182
+ }
2183
+ const base = opts.normalize !== false ? z18.string().transform((v) => v.trim().toUpperCase()) : z18.string();
2184
+ return base.pipe(
2185
+ z18.string().superRefine(async (value, ctx) => {
2186
+ if (opts.regex) {
2187
+ if (!opts.regex.test(value)) {
2188
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "postalCode", label: opts.label } });
2189
+ }
2190
+ return;
2191
+ }
2192
+ const resolved = mod ?? await loadPostalCodes();
2193
+ if (!resolved.postcodeValidatorExistsForCountry(country)) {
2194
+ if (!opts.customFn) {
2195
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "postalCode", label: opts.label } });
2196
+ }
2197
+ return;
2198
+ }
2199
+ if (!resolved.postcodeValidator(value, country)) {
2200
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "postalCode", label: opts.label } });
2201
+ }
2202
+ })
2203
+ );
2204
+ }
2205
+ });
2206
+
2207
+ // src/rules/slug.ts
2208
+ import { z as z19 } from "zod";
2209
+ var ESCAPE_REGEX_RE2 = /[.*+?^${}()|[\]\\]/g;
2210
+ var DEFAULT_SLUG_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
2211
+ function buildSlugPattern(extraChars) {
2212
+ if (extraChars !== void 0 && extraChars.length > 0) {
2213
+ const escaped = extraChars.replace(ESCAPE_REGEX_RE2, "\\$&");
2214
+ return new RegExp(`^[a-z0-9${escaped}]+(-[a-z0-9${escaped}]+)*$`);
2215
+ }
2216
+ return DEFAULT_SLUG_RE;
2217
+ }
2218
+ var Slug = /* @__PURE__ */ createRule({
2219
+ name: "slug",
2220
+ defaults: {},
2221
+ messages: {},
2222
+ build: (opts) => {
2223
+ const range = resolveRange(opts.length);
2224
+ const min = range?.min ?? 1;
2225
+ const max = range?.max ?? 100;
2226
+ const pattern = opts.regex ?? buildSlugPattern(opts.extraChars);
2227
+ const base = opts.normalize !== false ? z19.string().transform((v) => v.trim().toLowerCase()) : z19.string();
2228
+ const lbl = opts.label;
2229
+ return base.pipe(
2230
+ z19.string().superRefine((v, ctx) => {
2231
+ if (v.length < min) {
2232
+ ctx.addIssue({ code: "custom", params: { code: "min", namespace: "base", label: lbl, minimum: min } });
2233
+ return;
2234
+ }
2235
+ if (v.length > max) {
2236
+ ctx.addIssue({ code: "custom", params: { code: "max", namespace: "base", label: lbl, maximum: max } });
2237
+ return;
2238
+ }
2239
+ if (!pattern.test(v)) {
2240
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "slug", label: lbl } });
2241
+ }
2242
+ })
2243
+ );
2244
+ }
2245
+ });
2246
+
2247
+ // src/rules/text.ts
2248
+ import { z as z20 } from "zod";
2249
+ var Text = /* @__PURE__ */ createRule({
2250
+ name: "text",
2251
+ defaults: {},
2252
+ messages: {},
2253
+ build: (opts) => {
2254
+ const range = resolveRange(opts.length);
2255
+ const wordsRange = resolveRange(opts.words);
2256
+ const consecutiveRange = resolveRange(opts.consecutive);
2257
+ const base = opts.normalize !== false ? z20.string().trim() : z20.string();
2258
+ const lengthSchema = buildLengthSchema(range, opts.label);
2259
+ let schema = base.pipe(lengthSchema);
2260
+ if (opts.regex !== void 0) {
2261
+ const pattern = opts.regex;
2262
+ schema = schema.pipe(z20.string().refine(
2263
+ (v) => pattern.test(v),
2264
+ { params: { code: "invalid", namespace: "text", label: opts.label } }
2265
+ ));
2266
+ }
2267
+ if (opts.noEmails === true) {
2268
+ schema = schema.noEmails({ namespace: "text", label: opts.label });
2269
+ }
2270
+ if (opts.noUrls === true) {
2271
+ schema = schema.noUrls({ namespace: "text", label: opts.label });
2272
+ }
2273
+ if (opts.noHtml === true) {
2274
+ schema = schema.noHtml({ namespace: "text", label: opts.label });
2275
+ }
2276
+ if (opts.noPhoneNumbers === true) {
2277
+ schema = schema.noPhoneNumbers({ namespace: "text", label: opts.label });
2278
+ }
2279
+ if (wordsRange?.min !== void 0) {
2280
+ schema = schema.minWords({ min: wordsRange.min, namespace: "text", label: opts.label });
2281
+ }
2282
+ if (wordsRange?.max !== void 0) {
2283
+ schema = schema.maxWords({ max: wordsRange.max, namespace: "text", label: opts.label });
2284
+ }
2285
+ if (consecutiveRange?.max !== void 0) {
2286
+ schema = schema.maxConsecutive({ max: consecutiveRange.max, namespace: "text", label: opts.label });
2287
+ }
2288
+ return schema;
2289
+ }
2290
+ });
2291
+ function buildLengthSchema(range, label) {
2292
+ const min = range?.min;
2293
+ const max = range?.max;
2294
+ return z20.string().superRefine((v, ctx) => {
2295
+ applyLengthCheck(v, min, max, label, ctx);
2296
+ });
2297
+ }
2298
+
2299
+ // src/rules/token.ts
2300
+ import { z as z21 } from "zod";
2301
+ var TOKEN_SPECS = {
2302
+ nanoid: { pattern: /^[\w-]+$/, defaultLength: 21 },
2303
+ cuid: { pattern: /^c[a-z0-9]+$/, defaultLength: 25 },
2304
+ cuid2: { pattern: /^[a-z][a-z0-9]+$/, defaultLength: 24 },
2305
+ ulid: { pattern: /^[0-9A-HJKMNP-TV-Z]{26}$/i, defaultLength: 26 },
2306
+ hex: { pattern: /^[0-9a-f]+$/i },
2307
+ base64: { pattern: /^[A-Z0-9+/]+=*$/i }
2308
+ };
2309
+ var Token = /* @__PURE__ */ createRule({
2310
+ name: "token",
2311
+ defaults: {},
2312
+ messages: {},
2313
+ build: (opts) => {
2314
+ const spec = TOKEN_SPECS[opts.type];
2315
+ const range = resolveRange(opts.length);
2316
+ const schema = opts.normalize !== false ? z21.string().trim() : z21.string();
2317
+ const min = range?.min ?? spec.defaultLength ?? void 0;
2318
+ const max = range?.max ?? spec.defaultLength ?? void 0;
2319
+ const pattern = opts.regex ?? spec.pattern;
2320
+ const lbl = opts.label;
2321
+ const tokenType = opts.type;
2322
+ return schema.superRefine((v, ctx) => {
2323
+ if (min !== void 0 && v.length < min) {
2324
+ ctx.addIssue({ code: "custom", params: { code: "min", namespace: "base", label: lbl, minimum: min } });
2325
+ return;
2326
+ }
2327
+ if (max !== void 0 && v.length > max) {
2328
+ ctx.addIssue({ code: "custom", params: { code: "max", namespace: "base", label: lbl, maximum: max } });
2329
+ return;
2330
+ }
2331
+ if (!pattern.test(v)) {
2332
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "token", type: tokenType, label: lbl } });
2333
+ }
2334
+ });
2335
+ }
2336
+ });
2337
+
2338
+ // src/rules/url.ts
2339
+ import { z as z23 } from "zod";
2340
+
2341
+ // src/internal/formatChecks.ts
2342
+ import { z as z22 } from "zod";
2343
+ var URL_FORMAT_CHECK = z22.string().url();
2344
+
2345
+ // src/rules/url.ts
2346
+ var TRAILING_COLON_RE = /:$/;
2347
+ function parseUrlSafely(value) {
2348
+ try {
2349
+ return new URL(value);
2350
+ } catch {
2351
+ return void 0;
2352
+ }
2353
+ }
2354
+ function checkUrlConstraints(parsed, opts, ctx, ns, lbl, protocols, blockDomains, allowDomains) {
2355
+ const protocol = parsed.protocol.replace(TRAILING_COLON_RE, "");
2356
+ const { hostname } = parsed;
2357
+ if (protocols.length > 0 && !protocols.includes(protocol)) {
2358
+ ctx.addIssue({ code: "custom", params: { code: "protocolNotAllowed", namespace: ns, protocol, label: lbl } });
2359
+ }
2360
+ if (opts.requireTLD === true && !hostname.includes(".")) {
2361
+ ctx.addIssue({ code: "custom", params: { code: "tldRequired", namespace: ns, label: lbl } });
2362
+ }
2363
+ if (opts.allowAuth !== true && (parsed.username !== "" || parsed.password !== "")) {
2364
+ ctx.addIssue({ code: "custom", params: { code: "authNotAllowed", namespace: ns, label: lbl } });
2365
+ }
2366
+ if (blockDomains.length > 0 && matchesDomainList(hostname, blockDomains)) {
2367
+ ctx.addIssue({ code: "custom", params: { code: "domainBlocked", namespace: ns, domain: hostname, label: lbl } });
2368
+ }
2369
+ if (allowDomains.length > 0 && !matchesDomainList(hostname, allowDomains)) {
2370
+ ctx.addIssue({ code: "custom", params: { code: "domainNotAllowed", namespace: ns, domain: hostname, label: lbl } });
2371
+ }
2372
+ if (opts.allowQuery === false && parsed.search !== "") {
2373
+ ctx.addIssue({ code: "custom", params: { code: "queryNotAllowed", namespace: ns, label: lbl } });
2374
+ }
2375
+ }
2376
+ var Url = /* @__PURE__ */ createRule({
2377
+ name: "url",
2378
+ defaults: {},
2379
+ messages: {},
2380
+ build: (opts) => {
2381
+ const range = resolveRange(opts.length);
2382
+ const max = range?.max ?? 2048;
2383
+ const protocols = opts.protocols ?? ["http", "https"];
2384
+ const min = range?.min;
2385
+ const base = opts.normalize !== false ? z23.string().trim() : z23.string();
2386
+ const lbl = opts.label;
2387
+ const ns = "url";
2388
+ const blockDomains = opts.blockDomains ?? [];
2389
+ const allowDomains = opts.allowDomains ?? [];
2390
+ return base.pipe(z23.string().superRefine((v, ctx) => {
2391
+ applyLengthCheck(v, min, max, lbl, ctx);
2392
+ if (!URL_FORMAT_CHECK.safeParse(v).success) {
2393
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: ns, label: lbl } });
2394
+ return;
2395
+ }
2396
+ const parsed = parseUrlSafely(v);
2397
+ if (parsed === void 0)
2398
+ return;
2399
+ checkUrlConstraints(parsed, opts, ctx, ns, lbl, protocols, blockDomains, allowDomains);
2400
+ }));
2401
+ }
2402
+ });
2403
+
2404
+ // src/rules/username.ts
2405
+ import { z as z24 } from "zod";
2406
+ var PATTERN_MAP = {
2407
+ "alphanumeric": "a-z0-9",
2408
+ "alphanumeric-dash": "a-z0-9\\-",
2409
+ "alphanumeric-underscore": "a-z0-9_"
2410
+ };
2411
+ function buildUsernamePattern(pattern, extraChars, disallowChars) {
2412
+ let charClass = PATTERN_MAP[pattern] ?? "a-z0-9_";
2413
+ if (extraChars !== void 0 && extraChars.length > 0) {
2414
+ charClass += escapeRegexChars(extraChars);
2415
+ }
2416
+ if (disallowChars !== void 0) {
2417
+ for (const ch of disallowChars) {
2418
+ charClass = charClass.replaceAll(escapeRegexChars(ch), "");
2419
+ }
2420
+ }
2421
+ return new RegExp(`^[${charClass}]+$`);
2422
+ }
2423
+ function applyReservedRefine(schema, ignoreCase, customReserved, label) {
2424
+ return schema.superRefine(async (v, ctx) => {
2425
+ if (typeof v !== "string")
2426
+ return;
2427
+ const normalized = ignoreCase ? v.toLowerCase() : v;
2428
+ if (customReserved.length > 0) {
2429
+ const customSet = customReserved.map((w) => ignoreCase ? w.toLowerCase() : w);
2430
+ if (customSet.includes(normalized)) {
2431
+ ctx.addIssue({ code: "custom", params: { code: "reservedBlocked", namespace: "username", value: normalized, label } });
2432
+ return;
2433
+ }
2434
+ }
2435
+ let isReserved = false;
2436
+ try {
2437
+ const reserved = getReservedUsernames();
2438
+ isReserved = reserved.has(normalized);
2439
+ } catch {
2440
+ const reserved = await loadReservedUsernames();
2441
+ isReserved = reserved.has(normalized);
2442
+ }
2443
+ if (isReserved) {
2444
+ ctx.addIssue({ code: "custom", params: { code: "reservedBlocked", namespace: "username", value: normalized, label } });
2445
+ }
2446
+ });
2447
+ }
2448
+ var Username = /* @__PURE__ */ createRule({
2449
+ name: "username",
2450
+ defaults: {},
2451
+ messages: {},
2452
+ build: (opts) => {
2453
+ const range = resolveRange(opts.length);
2454
+ const consecutiveRange = resolveRange(opts.consecutive);
2455
+ const boundary = resolveBoundary(opts.boundary);
2456
+ const min = range?.min ?? 3;
2457
+ const max = range?.max ?? 20;
2458
+ const pattern = opts.regex ?? buildUsernamePattern(
2459
+ opts.pattern ?? "alphanumeric-underscore",
2460
+ /* v8 ignore stop */
2461
+ opts.extraChars,
2462
+ opts.disallowChars
2463
+ );
2464
+ const base = opts.normalize !== false ? z24.string().transform((v) => v.trim().toLowerCase()) : z24.string();
2465
+ const lbl = opts.label;
2466
+ const stage1 = z24.string().superRefine((v, ctx) => {
2467
+ if (v.length < min) {
2468
+ ctx.addIssue({ code: "custom", params: { code: "min", namespace: "base", label: lbl, minimum: min } });
2469
+ return;
2470
+ }
2471
+ if (v.length > max) {
2472
+ ctx.addIssue({ code: "custom", params: { code: "max", namespace: "base", label: lbl, maximum: max } });
2473
+ return;
2474
+ }
2475
+ if (!pattern.test(v)) {
2476
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "username", label: lbl } });
2477
+ return;
2478
+ }
2479
+ if (boundary !== void 0 && !checkAsciiBoundary(v, boundary)) {
2480
+ ctx.addIssue({ code: "custom", params: { code: "boundary", namespace: "username", label: lbl } });
2481
+ }
2482
+ });
2483
+ let stage2 = z24.string();
2484
+ if (consecutiveRange?.max !== void 0) {
2485
+ stage2 = stage2.maxConsecutive({ max: consecutiveRange.max, namespace: "username", label: lbl });
2486
+ }
2487
+ let inner = stage1.pipe(stage2);
2488
+ if (opts.blockReserved === true) {
2489
+ inner = applyReservedRefine(
2490
+ inner,
2491
+ opts.ignoreCase !== false,
2492
+ opts.reservedWords ?? [],
2493
+ opts.label
2494
+ );
2495
+ }
2496
+ return base.pipe(inner);
2497
+ }
2498
+ });
2499
+
2500
+ // src/rules/uuid.ts
2501
+ import { z as z25 } from "zod";
2502
+ var UUID_VERSION_INDEX = 14;
2503
+ var UUID_FORMAT_CHECK2 = z25.string().uuid();
2504
+ var Uuid = /* @__PURE__ */ createRule({
2505
+ name: "uuid",
2506
+ defaults: {},
2507
+ messages: {},
2508
+ build: (opts) => {
2509
+ const base = opts.normalize !== false ? z25.string().trim().toLowerCase() : z25.string();
2510
+ let schema = base.pipe(z25.string().superRefine((v, ctx) => {
2511
+ if (!UUID_FORMAT_CHECK2.safeParse(v).success) {
2512
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: "uuid", label: opts.label } });
2513
+ }
2514
+ }));
2515
+ if (opts.version !== void 0 && opts.version !== "any") {
2516
+ const expected = String(opts.version);
2517
+ schema = schema.refine(
2518
+ (v) => typeof v === "string" && v.charAt(UUID_VERSION_INDEX) === expected,
2519
+ { params: { code: "invalid", namespace: "uuid", label: opts.label } }
2520
+ );
2521
+ }
2522
+ return schema;
2523
+ }
2524
+ });
2525
+
2526
+ // src/rules/vatNumber.ts
2527
+ import { z as z26 } from "zod";
2528
+ var WHITESPACE_RE = /\s+/g;
2529
+ async function resolveVatPatterns() {
2530
+ try {
2531
+ return getVatPatterns();
2532
+ } catch {
2533
+ return loadVatPatterns();
2534
+ }
2535
+ }
2536
+ function extractCountryAndNumber(value, country, requirePrefix) {
2537
+ if (country === void 0 || country === "") {
2538
+ const cc = value.slice(0, 2);
2539
+ return [cc, value.slice(2)];
2540
+ }
2541
+ if (requirePrefix) {
2542
+ if (!value.startsWith(country))
2543
+ return null;
2544
+ return [country, value.slice(country.length)];
2545
+ }
2546
+ const numberPart = value.startsWith(country) ? value.slice(country.length) : value;
2547
+ return [country, numberPart];
2548
+ }
2549
+ var VatNumber = /* @__PURE__ */ createRule({
2550
+ name: "vatNumber",
2551
+ defaults: {},
2552
+ messages: {},
2553
+ build: (opts) => {
2554
+ const requirePrefix = opts.requirePrefix ?? false;
2555
+ const schema = opts.normalize !== false ? z26.string().transform(
2556
+ (v) => v.trim().toUpperCase().replace(WHITESPACE_RE, "")
2557
+ ) : z26.string();
2558
+ return schema.pipe(
2559
+ z26.string().refine(
2560
+ async (value) => {
2561
+ const patterns = await resolveVatPatterns();
2562
+ const parts = extractCountryAndNumber(
2563
+ value,
2564
+ opts.country,
2565
+ requirePrefix
2566
+ );
2567
+ if (!parts)
2568
+ return false;
2569
+ const [cc, numberPart] = parts;
2570
+ const pattern = patterns.get(cc);
2571
+ if (!pattern)
2572
+ return false;
2573
+ return pattern.test(numberPart);
2574
+ },
2575
+ { params: { code: "invalid", namespace: "vatNumber", label: opts.label } }
2576
+ )
2577
+ );
2578
+ }
2579
+ });
2580
+
2581
+ // src/rules/website.ts
2582
+ import { z as z27 } from "zod";
2583
+ var PROTOCOL_PREFIX_RE = /^[a-z][a-z\d+\-.]*:/i;
2584
+ function normalizeWebsiteInput(value) {
2585
+ const normalized = value.trim().toLowerCase();
2586
+ if (PROTOCOL_PREFIX_RE.test(normalized))
2587
+ return normalized;
2588
+ return `https://${normalized}`;
2589
+ }
2590
+ function isBaseDomain(hostname) {
2591
+ const stripped = hostname.startsWith("www.") ? hostname.slice(4) : hostname;
2592
+ return stripped.split(".").length <= 2;
2593
+ }
2594
+ function checkWebsiteConstraints(parsed, opts, ctx, ns, lbl, blockDomains, allowDomains) {
2595
+ const { protocol, hostname, pathname, search } = parsed;
2596
+ const isHttp = protocol === "http:" || protocol === "https:";
2597
+ if (!isHttp) {
2598
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: ns, label: lbl } });
2599
+ return;
2600
+ }
2601
+ if (opts.requireHttps === true && protocol !== "https:") {
2602
+ ctx.addIssue({ code: "custom", params: { code: "httpsRequired", namespace: ns, label: lbl } });
2603
+ }
2604
+ if (opts.requireWww === true && !hostname.startsWith("www.")) {
2605
+ ctx.addIssue({ code: "custom", params: { code: "wwwRequired", namespace: ns, label: lbl } });
2606
+ }
2607
+ if (blockDomains.length > 0 && matchesDomainList(hostname, blockDomains)) {
2608
+ ctx.addIssue({ code: "custom", params: { code: "domainBlocked", namespace: ns, domain: hostname, label: lbl } });
2609
+ }
2610
+ if (allowDomains.length > 0 && !matchesDomainList(hostname, allowDomains)) {
2611
+ ctx.addIssue({ code: "custom", params: { code: "domainNotAllowed", namespace: ns, domain: hostname, label: lbl } });
2612
+ }
2613
+ if (opts.allowSubdomains === false && !isBaseDomain(hostname)) {
2614
+ ctx.addIssue({ code: "custom", params: { code: "subdomainNotAllowed", namespace: ns, label: lbl } });
2615
+ }
2616
+ if (opts.allowPath === false && pathname !== "/" && pathname !== "") {
2617
+ ctx.addIssue({ code: "custom", params: { code: "pathNotAllowed", namespace: ns, label: lbl } });
2618
+ }
2619
+ if (opts.allowQuery !== true && search !== "") {
2620
+ ctx.addIssue({ code: "custom", params: { code: "queryNotAllowed", namespace: ns, label: lbl } });
2621
+ }
2622
+ }
2623
+ var Website = /* @__PURE__ */ createRule({
2624
+ name: "website",
2625
+ defaults: {},
2626
+ messages: {},
2627
+ build: (opts) => {
2628
+ const range = resolveRange(opts.length);
2629
+ const max = range?.max ?? 255;
2630
+ const min = range?.min;
2631
+ const lbl = opts.label;
2632
+ const ns = "website";
2633
+ const blockDomains = opts.blockDomains ?? [];
2634
+ const allowDomains = opts.allowDomains ?? [];
2635
+ const base = opts.normalize !== false ? z27.string().transform(normalizeWebsiteInput) : z27.string();
2636
+ return base.pipe(z27.string().superRefine((v, ctx) => {
2637
+ applyLengthCheck(v, min, max, lbl, ctx);
2638
+ if (!URL_FORMAT_CHECK.safeParse(v).success) {
2639
+ ctx.addIssue({ code: "custom", params: { code: "invalid", namespace: ns, label: lbl } });
2640
+ return;
2641
+ }
2642
+ try {
2643
+ checkWebsiteConstraints(new URL(v), opts, ctx, ns, lbl, blockDomains, allowDomains);
2644
+ } catch {
2645
+ }
2646
+ }));
2647
+ }
2648
+ });
2649
+
2650
+ export {
2651
+ getConfig,
2652
+ resetConfig,
2653
+ getErrorMessage,
2654
+ fieldNameToLabel,
2655
+ getParams,
2656
+ initAugmentation,
2657
+ configure,
2658
+ setup,
2659
+ getConfig2,
2660
+ preloadData,
2661
+ getCrossField,
2662
+ createRule,
2663
+ BusinessName,
2664
+ Color,
2665
+ Country,
2666
+ CreditCard,
2667
+ Currency,
2668
+ DateTime,
2669
+ Email,
2670
+ Iban,
2671
+ IpAddress,
2672
+ Jwt,
2673
+ LicenseKey,
2674
+ MacAddress,
2675
+ Password,
2676
+ PasswordConfirmation,
2677
+ PersonName,
2678
+ Phone,
2679
+ PostalCode,
2680
+ Slug,
2681
+ Text,
2682
+ Token,
2683
+ Url,
2684
+ Username,
2685
+ Uuid,
2686
+ VatNumber,
2687
+ Website
2688
+ };