@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
package/dist/index.cjs ADDED
@@ -0,0 +1,361 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+ var _chunkPQ4TUE2Qcjs = require('./chunk-PQ4TUE2Q.cjs');
40
+ require('./chunk-TSPTIW3V.cjs');
41
+ require('./chunk-OCTLUBGT.cjs');
42
+ require('./chunk-WE2OD5XD.cjs');
43
+ require('./chunk-2OTGUKO7.cjs');
44
+ require('./chunk-5CYBSNNG.cjs');
45
+ require('./chunk-D232V332.cjs');
46
+ require('./chunk-P3FRVJ3U.cjs');
47
+ require('./chunk-ZWIO2MJX.cjs');
48
+ require('./chunk-ZAUX2RGL.cjs');
49
+ require('./chunk-JEKRBIPN.cjs');
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+ var _chunkOFT3FQPJcjs = require('./chunk-OFT3FQPJ.cjs');
73
+
74
+
75
+
76
+ var _chunkH3XHQLZFcjs = require('./chunk-H3XHQLZF.cjs');
77
+ require('./chunk-ISY3F7TI.cjs');
78
+
79
+
80
+ var _chunkLSQNDPFQcjs = require('./chunk-LSQNDPFQ.cjs');
81
+ require('./chunk-64X6D23X.cjs');
82
+
83
+ // src/core/validate.ts
84
+ var _zod = require('zod');
85
+
86
+ // src/core/crossFieldResolver.ts
87
+
88
+ function deriveFieldLabel(fieldName, explicitLabel, prefix) {
89
+ if (explicitLabel !== void 0)
90
+ return explicitLabel;
91
+ const config = _chunkPQ4TUE2Qcjs.getConfig.call(void 0, );
92
+ const fallback = _nullishCoalesce(_optionalChain([config, 'access', _ => _.label, 'optionalAccess', _2 => _2.fallback]), () => ( "derived"));
93
+ let defaultLabel;
94
+ if (fallback === "none")
95
+ defaultLabel = "";
96
+ else if (fallback === "generic")
97
+ defaultLabel = "This field";
98
+ else
99
+ defaultLabel = _chunkPQ4TUE2Qcjs.fieldNameToLabel.call(void 0, fieldName);
100
+ if (_optionalChain([config, 'access', _3 => _3.label, 'optionalAccess', _4 => _4.transform]) !== void 0) {
101
+ const path = [..._nullishCoalesce(prefix, () => ( [])), fieldName];
102
+ return config.label.transform({ path, fieldName, defaultLabel });
103
+ }
104
+ return defaultLabel;
105
+ }
106
+ function resolveCrossFieldMessage(namespace, code, params) {
107
+ const config = _chunkPQ4TUE2Qcjs.getConfig.call(void 0, );
108
+ const i18n = config.i18n;
109
+ const pfx = _nullishCoalesce(i18n.prefix, () => ( "validation"));
110
+ const sep = _nullishCoalesce(i18n.separator, () => ( "."));
111
+ const key = [pfx, "messages", namespace, code].join(sep);
112
+ if (i18n.enabled && i18n.t !== void 0)
113
+ return i18n.t(key, params);
114
+ if (i18n.enabled)
115
+ return key;
116
+ return _chunkPQ4TUE2Qcjs.getErrorMessage.call(void 0, namespace, code, params);
117
+ }
118
+ function resolveSameAs(fieldName, sameAs2, shape, parsedData, meta, prefix) {
119
+ if (!(sameAs2 in shape)) {
120
+ throw new Error(
121
+ `validex: sameAs("${sameAs2}") on field "${fieldName}" \u2014 target field "${sameAs2}" does not exist in the schema`
122
+ );
123
+ }
124
+ const sourceValue = _optionalChain([parsedData, 'optionalAccess', _5 => _5[fieldName]]);
125
+ const targetValue = _optionalChain([parsedData, 'optionalAccess', _6 => _6[sameAs2]]);
126
+ if (sourceValue === targetValue)
127
+ return void 0;
128
+ const targetSchema = shape[sameAs2];
129
+ const targetMeta = targetSchema !== void 0 ? _chunkPQ4TUE2Qcjs.getCrossField.call(void 0, targetSchema) : void 0;
130
+ const label = deriveFieldLabel(fieldName, meta.label, prefix);
131
+ const targetLabel = deriveFieldLabel(sameAs2, _optionalChain([targetMeta, 'optionalAccess', _7 => _7.label]), prefix);
132
+ return {
133
+ path: [...prefix, fieldName],
134
+ message: resolveCrossFieldMessage("confirmation", "mismatch", {
135
+ label,
136
+ targetLabel,
137
+ code: "mismatch",
138
+ namespace: "confirmation"
139
+ })
140
+ };
141
+ }
142
+ function resolveRequiredWhen(fieldName, targetName, parsedData, rawObj, fieldErrors, meta, prefix) {
143
+ const targetDotPath = [...prefix, targetName].join(".");
144
+ if (fieldErrors.has(targetDotPath))
145
+ return void 0;
146
+ const targetValue = _optionalChain([parsedData, 'optionalAccess', _8 => _8[targetName]]);
147
+ if (targetValue === void 0 || targetValue === null || targetValue === "")
148
+ return void 0;
149
+ const rawValue = rawObj[fieldName];
150
+ if (rawValue !== void 0 && rawValue !== null && rawValue !== "")
151
+ return void 0;
152
+ const label = deriveFieldLabel(fieldName, meta.label, prefix);
153
+ return {
154
+ path: [...prefix, fieldName],
155
+ message: resolveCrossFieldMessage("base", "required", {
156
+ label,
157
+ code: "required",
158
+ namespace: "base"
159
+ })
160
+ };
161
+ }
162
+ function resolveFieldConstraint(fieldName, shape, parsedData, rawObj, fieldErrors, prefix) {
163
+ const fieldSchema = shape[fieldName];
164
+ if (fieldSchema === void 0)
165
+ return [];
166
+ const meta = _chunkPQ4TUE2Qcjs.getCrossField.call(void 0, fieldSchema);
167
+ if (meta === void 0)
168
+ return [];
169
+ const issues = [];
170
+ const dotPath = [...prefix, fieldName].join(".");
171
+ if (meta.sameAs !== void 0 && !fieldErrors.has(dotPath)) {
172
+ const issue = resolveSameAs(fieldName, meta.sameAs, shape, parsedData, meta, prefix);
173
+ if (issue !== void 0)
174
+ issues.push(issue);
175
+ }
176
+ if (meta.requiredWhen !== void 0) {
177
+ const issue = resolveRequiredWhen(fieldName, meta.requiredWhen, parsedData, rawObj, fieldErrors, meta, prefix);
178
+ if (issue !== void 0)
179
+ issues.push(issue);
180
+ }
181
+ return issues;
182
+ }
183
+ function resolveCrossFieldConstraints(schema, parsedData, fieldErrors, rawData, prefix = []) {
184
+ const shape = schema.shape;
185
+ const rawObj = typeof rawData === "object" && rawData !== null ? rawData : {};
186
+ const issues = [];
187
+ for (const fieldName of Object.keys(shape)) {
188
+ issues.push(...resolveFieldConstraint(fieldName, shape, parsedData, rawObj, fieldErrors, prefix));
189
+ }
190
+ for (const [fieldName, fieldSchema] of Object.entries(shape)) {
191
+ if (fieldSchema instanceof _zod.z.ZodObject) {
192
+ const nestedParsed = _optionalChain([parsedData, 'optionalAccess', _9 => _9[fieldName]]);
193
+ issues.push(...resolveCrossFieldConstraints(
194
+ fieldSchema,
195
+ nestedParsed,
196
+ fieldErrors,
197
+ rawObj[fieldName],
198
+ [...prefix, fieldName]
199
+ ));
200
+ }
201
+ }
202
+ return issues;
203
+ }
204
+
205
+ // src/core/validate.ts
206
+ function buildDotPath(path) {
207
+ return path.map(String).join(".");
208
+ }
209
+ function buildNestedErrors(issues) {
210
+ const root = {};
211
+ for (const issue of issues) {
212
+ const { path, message } = issue;
213
+ if (path.length === 0)
214
+ continue;
215
+ let current = root;
216
+ for (let i = 0; i < path.length - 1; i++) {
217
+ const segment = String(path[i]);
218
+ if (current[segment] === void 0)
219
+ current[segment] = {};
220
+ current = current[segment];
221
+ }
222
+ const lastSegment = String(path.at(-1));
223
+ const existing = current[lastSegment];
224
+ if (Array.isArray(existing))
225
+ existing.push(message);
226
+ else
227
+ current[lastSegment] = [message];
228
+ }
229
+ return root;
230
+ }
231
+ function collectIssues(issues, errors, firstErrors) {
232
+ for (const issue of issues) {
233
+ const dotPath = buildDotPath(issue.path);
234
+ if (errors[dotPath] === void 0) {
235
+ errors[dotPath] = [];
236
+ firstErrors[dotPath] = issue.message;
237
+ }
238
+ errors[dotPath].push(issue.message);
239
+ }
240
+ }
241
+ async function validate(schema, data) {
242
+ _chunkPQ4TUE2Qcjs.initAugmentation.call(void 0, );
243
+ const result = await schema.safeParseAsync(data);
244
+ if (result.success)
245
+ return handleSuccess(schema, result.data, data);
246
+ return handleFailure(schema, result.error, data);
247
+ }
248
+ function handleSuccess(schema, parsed, raw) {
249
+ if (schema instanceof _zod.z.ZodObject) {
250
+ const crossIssues = resolveCrossFieldConstraints(schema, parsed, /* @__PURE__ */ new Set(), raw);
251
+ if (crossIssues.length > 0) {
252
+ const errors = {};
253
+ const firstErrors = {};
254
+ collectIssues(crossIssues, errors, firstErrors);
255
+ return { success: false, errors, firstErrors, nestedErrors: buildNestedErrors(crossIssues), issues: crossIssues };
256
+ }
257
+ }
258
+ return {
259
+ success: true,
260
+ data: parsed,
261
+ // SAFETY: Zod safeParseAsync returns inferred output type on success
262
+ errors: {},
263
+ firstErrors: {},
264
+ nestedErrors: {},
265
+ issues: []
266
+ };
267
+ }
268
+ function handleFailure(schema, error, raw) {
269
+ const rawIssues = error.issues;
270
+ const errors = {};
271
+ const firstErrors = {};
272
+ const fieldErrors = /* @__PURE__ */ new Set();
273
+ for (const issue of rawIssues) {
274
+ const dotPath = buildDotPath(issue.path);
275
+ fieldErrors.add(dotPath);
276
+ if (errors[dotPath] === void 0) {
277
+ errors[dotPath] = [];
278
+ firstErrors[dotPath] = issue.message;
279
+ }
280
+ errors[dotPath].push(issue.message);
281
+ }
282
+ if (schema instanceof _zod.z.ZodObject) {
283
+ const rawObj = typeof raw === "object" && raw !== null ? raw : {};
284
+ const crossIssues = resolveCrossFieldConstraints(schema, rawObj, fieldErrors, raw);
285
+ collectIssues(crossIssues, errors, firstErrors);
286
+ if (crossIssues.length > 0) {
287
+ const allIssues = [...rawIssues, ...crossIssues];
288
+ return { success: false, errors, firstErrors, nestedErrors: buildNestedErrors(allIssues), issues: allIssues };
289
+ }
290
+ }
291
+ return {
292
+ success: false,
293
+ errors,
294
+ firstErrors,
295
+ nestedErrors: buildNestedErrors(rawIssues),
296
+ // SAFETY: issues escape hatch exposes raw Zod issues as ReadonlyArray<unknown> for consumers
297
+ issues: error.issues
298
+ };
299
+ }
300
+
301
+ // src/index.ts
302
+ _chunkPQ4TUE2Qcjs.initAugmentation.call(void 0, );
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+ exports.BusinessName = _chunkPQ4TUE2Qcjs.BusinessName; exports.Color = _chunkPQ4TUE2Qcjs.Color; exports.Country = _chunkPQ4TUE2Qcjs.Country; exports.CreditCard = _chunkPQ4TUE2Qcjs.CreditCard; exports.Currency = _chunkPQ4TUE2Qcjs.Currency; exports.DateTime = _chunkPQ4TUE2Qcjs.DateTime; exports.Email = _chunkPQ4TUE2Qcjs.Email; exports.Iban = _chunkPQ4TUE2Qcjs.Iban; exports.IpAddress = _chunkPQ4TUE2Qcjs.IpAddress; exports.Jwt = _chunkPQ4TUE2Qcjs.Jwt; exports.LicenseKey = _chunkPQ4TUE2Qcjs.LicenseKey; exports.MacAddress = _chunkPQ4TUE2Qcjs.MacAddress; exports.Password = _chunkPQ4TUE2Qcjs.Password; exports.PasswordConfirmation = _chunkPQ4TUE2Qcjs.PasswordConfirmation; exports.PersonName = _chunkPQ4TUE2Qcjs.PersonName; exports.Phone = _chunkPQ4TUE2Qcjs.Phone; exports.PostalCode = _chunkPQ4TUE2Qcjs.PostalCode; exports.Slug = _chunkPQ4TUE2Qcjs.Slug; exports.Text = _chunkPQ4TUE2Qcjs.Text; exports.Token = _chunkPQ4TUE2Qcjs.Token; exports.Url = _chunkPQ4TUE2Qcjs.Url; exports.Username = _chunkPQ4TUE2Qcjs.Username; exports.Uuid = _chunkPQ4TUE2Qcjs.Uuid; exports.VatNumber = _chunkPQ4TUE2Qcjs.VatNumber; exports.Website = _chunkPQ4TUE2Qcjs.Website; exports.collapseWhitespace = _chunkOFT3FQPJcjs.collapseWhitespace; exports.configure = _chunkPQ4TUE2Qcjs.configure; exports.containsEmail = _chunkOFT3FQPJcjs.containsEmail; exports.containsHtml = _chunkOFT3FQPJcjs.containsHtml; exports.containsPhoneNumber = _chunkLSQNDPFQcjs.containsPhoneNumber; exports.containsUrl = _chunkOFT3FQPJcjs.containsUrl; exports.createRule = _chunkPQ4TUE2Qcjs.createRule; exports.emptyToUndefined = _chunkOFT3FQPJcjs.emptyToUndefined; exports.getConfig = _chunkPQ4TUE2Qcjs.getConfig2; exports.getParams = _chunkPQ4TUE2Qcjs.getParams; exports.hasDigits = _chunkOFT3FQPJcjs.hasDigits; exports.hasLowercase = _chunkOFT3FQPJcjs.hasLowercase; exports.hasSpecial = _chunkOFT3FQPJcjs.hasSpecial; exports.hasUppercase = _chunkOFT3FQPJcjs.hasUppercase; exports.maxConsecutive = _chunkOFT3FQPJcjs.maxConsecutive; exports.maxWords = _chunkOFT3FQPJcjs.maxWords; exports.minWords = _chunkOFT3FQPJcjs.minWords; exports.noSpaces = _chunkOFT3FQPJcjs.noSpaces; exports.onlyAlpha = _chunkOFT3FQPJcjs.onlyAlpha; exports.onlyAlphaSpaceHyphen = _chunkOFT3FQPJcjs.onlyAlphaSpaceHyphen; exports.onlyAlphanumeric = _chunkOFT3FQPJcjs.onlyAlphanumeric; exports.onlyAlphanumericSpaceHyphen = _chunkOFT3FQPJcjs.onlyAlphanumericSpaceHyphen; exports.onlyNumeric = _chunkOFT3FQPJcjs.onlyNumeric; exports.preloadData = _chunkPQ4TUE2Qcjs.preloadData; exports.requiredWhen = _chunkH3XHQLZFcjs.requiredWhen; exports.resetConfig = _chunkPQ4TUE2Qcjs.resetConfig; exports.sameAs = _chunkH3XHQLZFcjs.sameAs; exports.setup = _chunkPQ4TUE2Qcjs.setup; exports.stripHtml = _chunkOFT3FQPJcjs.stripHtml; exports.toSlug = _chunkOFT3FQPJcjs.toSlug; exports.toTitleCase = _chunkOFT3FQPJcjs.toTitleCase; exports.validate = validate;
@@ -0,0 +1,132 @@
1
+ import { G as GlobalConfig, P as PreloadOptions, B as BaseRuleOptions, C as CreateRuleOptions, R as RuleFactory, E as ErrorParams, V as ValidationResult } from './index-Cid7Ygr_.cjs';
2
+ export { a as Boundary, b as BusinessName, c as BusinessNameOptions, d as CheckMethodOptions, e as Color, f as ColorOptions, g as CompositionMethodOptions, h as Country, i as CountryOptions, j as CreditCard, k as CreditCardOptions, l as Currency, m as CurrencyOptions, D as DateTime, n as DateTimeOptions, o as Email, p as EmailOptions, F as FormatRuleOptions, I as I18nConfig, q as Iban, r as IbanOptions, s as IpAddress, t as IpAddressOptions, u as IssuerType, J as JWTOptions, v as Jwt, L as LabelConfig, w as LabelTransform, x as LicenseKey, y as LicenseKeyOptions, M as MacAddress, z as MacAddressOptions, A as MaxConsecutiveOptions, H as MaxWordsOptions, K as MessageConfig, N as MessageTransform, O as MinWordsOptions, Q as NestedErrors, S as Password, T as PasswordConfirmation, U as PasswordConfirmationOptions, W as PasswordOptions, X as PathTransform, Y as PersonName, Z as PersonNameOptions, _ as Phone, $ as PhoneOptions, a0 as PostalCode, a1 as PostalCodeOptions, a2 as Range, a3 as RuleDefaults, a4 as Slug, a5 as SlugOptions, a6 as Text, a7 as TextOptions, a8 as Token, a9 as TokenOptions, aa as TokenType, ab as TranslationFunction, ac as URLOptions, ad as UUIDOptions, ae as Url, af as Username, ag as UsernameOptions, ah as Uuid, ai as VatNumber, aj as VatNumberOptions, ak as Website, al as WebsiteOptions } from './index-Cid7Ygr_.cjs';
3
+ export { collapseWhitespace, containsEmail, containsHtml, containsPhoneNumber, containsUrl, emptyToUndefined, hasDigits, hasLowercase, hasSpecial, hasUppercase, maxConsecutive, maxWords, minWords, noSpaces, onlyAlpha, onlyAlphaSpaceHyphen, onlyAlphanumeric, onlyAlphanumericSpaceHyphen, onlyNumeric, stripHtml, toSlug, toTitleCase } from './checks/index.cjs';
4
+ import { z } from 'zod';
5
+ export { requiredWhen, sameAs } from './utilities/index.cjs';
6
+
7
+ /**
8
+ * Reset Config
9
+ * Resets configuration to defaults. Used for testing only.
10
+ */
11
+ declare function resetConfig(): void;
12
+
13
+ /**
14
+ * Configure
15
+ * Deep-merges the given config into the current global configuration.
16
+ * Can be called multiple times — each call merges, never replaces.
17
+ * Does NOT register the Zod customError handler (use setup() for that).
18
+ *
19
+ * @param config - Partial configuration to merge.
20
+ */
21
+ declare function configure(config: Partial<GlobalConfig>): void;
22
+ /**
23
+ * Setup
24
+ * Configures validex globally and registers the customError handler with Zod.
25
+ * Deep merges with existing config if called multiple times.
26
+ *
27
+ * @param config - Partial configuration to apply.
28
+ */
29
+ declare function setup(config?: Partial<GlobalConfig>): void;
30
+ /**
31
+ * Get Config
32
+ * Returns the current global configuration.
33
+ *
34
+ * @returns The current readonly global configuration.
35
+ */
36
+ declare function getConfig(): Readonly<GlobalConfig>;
37
+ /**
38
+ * Preload Data
39
+ * Preloads async data files at startup so that sync .parse() works everywhere.
40
+ * Safe to call multiple times — already-loaded data is cached.
41
+ *
42
+ * @param options - Which data files to preload.
43
+ * @returns A promise that resolves when all requested data is loaded.
44
+ */
45
+ declare function preloadData(options: PreloadOptions): Promise<void>;
46
+
47
+ /**
48
+ * Create Rule
49
+ * Factory that builds a reusable validation rule with three-tier merge,
50
+ * empty-to-undefined preprocessing, and optional custom validation.
51
+ *
52
+ * @param config - The rule configuration object.
53
+ * @returns A RuleFactory function that accepts per-call options.
54
+ */
55
+ declare function createRule<T extends BaseRuleOptions>(config: CreateRuleOptions<T>): RuleFactory<T>;
56
+
57
+ /**
58
+ * ZodIssueInput
59
+ * Minimal shape of a Zod issue used for parameter extraction.
60
+ */
61
+ interface ZodIssueInput {
62
+ readonly code?: string | undefined;
63
+ readonly path?: ReadonlyArray<string | number> | undefined;
64
+ readonly minimum?: unknown;
65
+ readonly maximum?: unknown;
66
+ readonly expected?: string | undefined;
67
+ readonly received?: string | undefined;
68
+ readonly input?: unknown;
69
+ readonly format?: string | undefined;
70
+ readonly params?: Readonly<Record<string, unknown>> | undefined;
71
+ }
72
+ /**
73
+ * Get Params
74
+ * Extracts validex ErrorParams from a Zod issue object.
75
+ *
76
+ * @param issue - A Zod issue (typed loosely for forward compatibility).
77
+ * @returns The normalized ErrorParams for the issue.
78
+ */
79
+ declare function getParams(issue: ZodIssueInput): ErrorParams;
80
+
81
+ /**
82
+ * Validate
83
+ * Runs Zod's safeParseAsync, resolves cross-field constraints (sameAs,
84
+ * requiredWhen), and returns a structured ValidationResult.
85
+ *
86
+ * @param schema - The Zod schema to validate against.
87
+ * @param data - The unknown data to validate.
88
+ * @returns A promise resolving to a typed ValidationResult.
89
+ */
90
+ declare function validate<T extends z.ZodType>(schema: T, data: unknown): Promise<ValidationResult<z.output<T>>>;
91
+
92
+ /** Valid boundary character constraint values. */
93
+ type BoundaryValue = 'alpha' | 'alphanumeric' | 'any';
94
+ /**
95
+ * ResolvedBoundary
96
+ * Normalized boundary with start and end constraints.
97
+ */
98
+ interface ResolvedBoundary {
99
+ readonly start: BoundaryValue;
100
+ readonly end: BoundaryValue;
101
+ }
102
+
103
+ /**
104
+ * ResolvedRange
105
+ * Normalized range with optional min and max.
106
+ */
107
+ interface ResolvedRange {
108
+ readonly min?: number;
109
+ readonly max?: number;
110
+ }
111
+
112
+ /** CountryData — a single ISO 3166-1 country entry. */
113
+ interface CountryData {
114
+ readonly alpha2: string;
115
+ readonly alpha3: string;
116
+ readonly name: string;
117
+ }
118
+
119
+ /** CardIssuer -- identification data for a single card network. */
120
+ interface CardIssuer {
121
+ readonly name: string;
122
+ readonly prefixes: readonly string[];
123
+ readonly lengths: readonly number[];
124
+ }
125
+
126
+ /** IbanPattern — IBAN length and structural regex for one country. */
127
+ interface IbanPattern {
128
+ readonly length: number;
129
+ readonly regex: RegExp;
130
+ }
131
+
132
+ export { BaseRuleOptions, type CardIssuer, type CountryData, CreateRuleOptions, ErrorParams, GlobalConfig, type IbanPattern, PreloadOptions, type ResolvedBoundary, type ResolvedRange, RuleFactory, ValidationResult, configure, createRule, getConfig, getParams, preloadData, resetConfig, setup, validate };
@@ -0,0 +1,132 @@
1
+ import { G as GlobalConfig, P as PreloadOptions, B as BaseRuleOptions, C as CreateRuleOptions, R as RuleFactory, E as ErrorParams, V as ValidationResult } from './index-Cid7Ygr_.js';
2
+ export { a as Boundary, b as BusinessName, c as BusinessNameOptions, d as CheckMethodOptions, e as Color, f as ColorOptions, g as CompositionMethodOptions, h as Country, i as CountryOptions, j as CreditCard, k as CreditCardOptions, l as Currency, m as CurrencyOptions, D as DateTime, n as DateTimeOptions, o as Email, p as EmailOptions, F as FormatRuleOptions, I as I18nConfig, q as Iban, r as IbanOptions, s as IpAddress, t as IpAddressOptions, u as IssuerType, J as JWTOptions, v as Jwt, L as LabelConfig, w as LabelTransform, x as LicenseKey, y as LicenseKeyOptions, M as MacAddress, z as MacAddressOptions, A as MaxConsecutiveOptions, H as MaxWordsOptions, K as MessageConfig, N as MessageTransform, O as MinWordsOptions, Q as NestedErrors, S as Password, T as PasswordConfirmation, U as PasswordConfirmationOptions, W as PasswordOptions, X as PathTransform, Y as PersonName, Z as PersonNameOptions, _ as Phone, $ as PhoneOptions, a0 as PostalCode, a1 as PostalCodeOptions, a2 as Range, a3 as RuleDefaults, a4 as Slug, a5 as SlugOptions, a6 as Text, a7 as TextOptions, a8 as Token, a9 as TokenOptions, aa as TokenType, ab as TranslationFunction, ac as URLOptions, ad as UUIDOptions, ae as Url, af as Username, ag as UsernameOptions, ah as Uuid, ai as VatNumber, aj as VatNumberOptions, ak as Website, al as WebsiteOptions } from './index-Cid7Ygr_.js';
3
+ export { collapseWhitespace, containsEmail, containsHtml, containsPhoneNumber, containsUrl, emptyToUndefined, hasDigits, hasLowercase, hasSpecial, hasUppercase, maxConsecutive, maxWords, minWords, noSpaces, onlyAlpha, onlyAlphaSpaceHyphen, onlyAlphanumeric, onlyAlphanumericSpaceHyphen, onlyNumeric, stripHtml, toSlug, toTitleCase } from './checks/index.js';
4
+ import { z } from 'zod';
5
+ export { requiredWhen, sameAs } from './utilities/index.js';
6
+
7
+ /**
8
+ * Reset Config
9
+ * Resets configuration to defaults. Used for testing only.
10
+ */
11
+ declare function resetConfig(): void;
12
+
13
+ /**
14
+ * Configure
15
+ * Deep-merges the given config into the current global configuration.
16
+ * Can be called multiple times — each call merges, never replaces.
17
+ * Does NOT register the Zod customError handler (use setup() for that).
18
+ *
19
+ * @param config - Partial configuration to merge.
20
+ */
21
+ declare function configure(config: Partial<GlobalConfig>): void;
22
+ /**
23
+ * Setup
24
+ * Configures validex globally and registers the customError handler with Zod.
25
+ * Deep merges with existing config if called multiple times.
26
+ *
27
+ * @param config - Partial configuration to apply.
28
+ */
29
+ declare function setup(config?: Partial<GlobalConfig>): void;
30
+ /**
31
+ * Get Config
32
+ * Returns the current global configuration.
33
+ *
34
+ * @returns The current readonly global configuration.
35
+ */
36
+ declare function getConfig(): Readonly<GlobalConfig>;
37
+ /**
38
+ * Preload Data
39
+ * Preloads async data files at startup so that sync .parse() works everywhere.
40
+ * Safe to call multiple times — already-loaded data is cached.
41
+ *
42
+ * @param options - Which data files to preload.
43
+ * @returns A promise that resolves when all requested data is loaded.
44
+ */
45
+ declare function preloadData(options: PreloadOptions): Promise<void>;
46
+
47
+ /**
48
+ * Create Rule
49
+ * Factory that builds a reusable validation rule with three-tier merge,
50
+ * empty-to-undefined preprocessing, and optional custom validation.
51
+ *
52
+ * @param config - The rule configuration object.
53
+ * @returns A RuleFactory function that accepts per-call options.
54
+ */
55
+ declare function createRule<T extends BaseRuleOptions>(config: CreateRuleOptions<T>): RuleFactory<T>;
56
+
57
+ /**
58
+ * ZodIssueInput
59
+ * Minimal shape of a Zod issue used for parameter extraction.
60
+ */
61
+ interface ZodIssueInput {
62
+ readonly code?: string | undefined;
63
+ readonly path?: ReadonlyArray<string | number> | undefined;
64
+ readonly minimum?: unknown;
65
+ readonly maximum?: unknown;
66
+ readonly expected?: string | undefined;
67
+ readonly received?: string | undefined;
68
+ readonly input?: unknown;
69
+ readonly format?: string | undefined;
70
+ readonly params?: Readonly<Record<string, unknown>> | undefined;
71
+ }
72
+ /**
73
+ * Get Params
74
+ * Extracts validex ErrorParams from a Zod issue object.
75
+ *
76
+ * @param issue - A Zod issue (typed loosely for forward compatibility).
77
+ * @returns The normalized ErrorParams for the issue.
78
+ */
79
+ declare function getParams(issue: ZodIssueInput): ErrorParams;
80
+
81
+ /**
82
+ * Validate
83
+ * Runs Zod's safeParseAsync, resolves cross-field constraints (sameAs,
84
+ * requiredWhen), and returns a structured ValidationResult.
85
+ *
86
+ * @param schema - The Zod schema to validate against.
87
+ * @param data - The unknown data to validate.
88
+ * @returns A promise resolving to a typed ValidationResult.
89
+ */
90
+ declare function validate<T extends z.ZodType>(schema: T, data: unknown): Promise<ValidationResult<z.output<T>>>;
91
+
92
+ /** Valid boundary character constraint values. */
93
+ type BoundaryValue = 'alpha' | 'alphanumeric' | 'any';
94
+ /**
95
+ * ResolvedBoundary
96
+ * Normalized boundary with start and end constraints.
97
+ */
98
+ interface ResolvedBoundary {
99
+ readonly start: BoundaryValue;
100
+ readonly end: BoundaryValue;
101
+ }
102
+
103
+ /**
104
+ * ResolvedRange
105
+ * Normalized range with optional min and max.
106
+ */
107
+ interface ResolvedRange {
108
+ readonly min?: number;
109
+ readonly max?: number;
110
+ }
111
+
112
+ /** CountryData — a single ISO 3166-1 country entry. */
113
+ interface CountryData {
114
+ readonly alpha2: string;
115
+ readonly alpha3: string;
116
+ readonly name: string;
117
+ }
118
+
119
+ /** CardIssuer -- identification data for a single card network. */
120
+ interface CardIssuer {
121
+ readonly name: string;
122
+ readonly prefixes: readonly string[];
123
+ readonly lengths: readonly number[];
124
+ }
125
+
126
+ /** IbanPattern — IBAN length and structural regex for one country. */
127
+ interface IbanPattern {
128
+ readonly length: number;
129
+ readonly regex: RegExp;
130
+ }
131
+
132
+ export { BaseRuleOptions, type CardIssuer, type CountryData, CreateRuleOptions, ErrorParams, GlobalConfig, type IbanPattern, PreloadOptions, type ResolvedBoundary, type ResolvedRange, RuleFactory, ValidationResult, configure, createRule, getConfig, getParams, preloadData, resetConfig, setup, validate };