@oxog/vld 2.1.0 → 2.2.5

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 (220) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +1296 -1235
  3. package/dist/chunks/errors-core-Cqi4-9ew.js +1 -0
  4. package/dist/chunks/index-CkbfQQ4n.js +1 -0
  5. package/dist/chunks/index-yjpbvFgw.js +1 -0
  6. package/dist/chunks/ip-validation-g5LWgy9t.js +1 -0
  7. package/dist/chunks/security-Dy24T8N7.js +1 -0
  8. package/dist/cjs/chunks/errors-core-DKPohm9I.cjs +1 -0
  9. package/dist/cjs/chunks/index-BEV9nG0N.cjs +1 -0
  10. package/dist/cjs/chunks/index-ZjHAxYdA.cjs +1 -0
  11. package/dist/cjs/chunks/ip-validation-BZqPamPC.cjs +1 -0
  12. package/dist/cjs/chunks/security-aXZVI7qW.cjs +1 -0
  13. package/dist/cjs/cli/bin.cjs +1 -505
  14. package/dist/cjs/cli/index.cjs +1 -209
  15. package/dist/cjs/codecs/index.cjs +1 -45
  16. package/dist/cjs/coercion/index.cjs +1 -588
  17. package/dist/cjs/compat/emitter.cjs +1 -184
  18. package/dist/cjs/compat/result.cjs +1 -189
  19. package/dist/cjs/errors.cjs +1 -180
  20. package/dist/cjs/index.cjs +1 -1894
  21. package/dist/cjs/kernel.cjs +1 -415
  22. package/dist/cjs/locales/af.cjs +1 -108
  23. package/dist/cjs/locales/ar.cjs +1 -108
  24. package/dist/cjs/locales/bn.cjs +1 -108
  25. package/dist/cjs/locales/da.cjs +1 -108
  26. package/dist/cjs/locales/de.cjs +1 -108
  27. package/dist/cjs/locales/en.cjs +1 -108
  28. package/dist/cjs/locales/es-MX.cjs +1 -107
  29. package/dist/cjs/locales/es.cjs +1 -96
  30. package/dist/cjs/locales/fi.cjs +1 -108
  31. package/dist/cjs/locales/fr.cjs +1 -96
  32. package/dist/cjs/locales/hi.cjs +1 -108
  33. package/dist/cjs/locales/id.cjs +1 -108
  34. package/dist/cjs/locales/index.cjs +1 -43
  35. package/dist/cjs/locales/it.cjs +1 -108
  36. package/dist/cjs/locales/ja.cjs +1 -108
  37. package/dist/cjs/locales/ko.cjs +1 -108
  38. package/dist/cjs/locales/lazy.cjs +1 -188
  39. package/dist/cjs/locales/nl.cjs +1 -108
  40. package/dist/cjs/locales/no.cjs +1 -108
  41. package/dist/cjs/locales/pl.cjs +1 -108
  42. package/dist/cjs/locales/pt-BR.cjs +1 -108
  43. package/dist/cjs/locales/pt.cjs +1 -108
  44. package/dist/cjs/locales/ru.cjs +1 -108
  45. package/dist/cjs/locales/runtime.cjs +1 -51
  46. package/dist/cjs/locales/sv.cjs +1 -108
  47. package/dist/cjs/locales/sw.cjs +1 -108
  48. package/dist/cjs/locales/th.cjs +1 -108
  49. package/dist/cjs/locales/tr.cjs +1 -108
  50. package/dist/cjs/locales/vi.cjs +1 -108
  51. package/dist/cjs/locales/zh.cjs +1 -108
  52. package/dist/cjs/mini.cjs +1 -242
  53. package/dist/cjs/pigment.cjs +1 -207
  54. package/dist/cjs/plugins/index.cjs +1 -12
  55. package/dist/cjs/registry.cjs +1 -37
  56. package/dist/cjs/v3/index.cjs +1 -425
  57. package/dist/cjs/v4/core/index.cjs +1 -894
  58. package/dist/cjs/v4/index.cjs +1 -425
  59. package/dist/cjs/v4/locales/index.cjs +1 -130
  60. package/dist/cjs/v4/mini/index.cjs +1 -509
  61. package/dist/cjs/v4-mini/index.cjs +1 -532
  62. package/dist/cjs/validators/any.cjs +1 -40
  63. package/dist/cjs/validators/array.cjs +1 -283
  64. package/dist/cjs/validators/base.cjs +1 -887
  65. package/dist/cjs/validators/base64.cjs +1 -73
  66. package/dist/cjs/validators/bigint.cjs +1 -232
  67. package/dist/cjs/validators/boolean.cjs +1 -146
  68. package/dist/cjs/validators/codec.cjs +1 -205
  69. package/dist/cjs/validators/custom.cjs +1 -71
  70. package/dist/cjs/validators/date.cjs +1 -278
  71. package/dist/cjs/validators/discriminated-union.cjs +1 -130
  72. package/dist/cjs/validators/enum.cjs +1 -154
  73. package/dist/cjs/validators/file.cjs +1 -130
  74. package/dist/cjs/validators/function.cjs +1 -63
  75. package/dist/cjs/validators/hex.cjs +1 -70
  76. package/dist/cjs/validators/index.cjs +1 -123
  77. package/dist/cjs/validators/intersection.cjs +1 -120
  78. package/dist/cjs/validators/json.cjs +1 -70
  79. package/dist/cjs/validators/lazy.cjs +1 -53
  80. package/dist/cjs/validators/literal.cjs +1 -64
  81. package/dist/cjs/validators/map.cjs +1 -218
  82. package/dist/cjs/validators/nan.cjs +1 -41
  83. package/dist/cjs/validators/never.cjs +1 -36
  84. package/dist/cjs/validators/null.cjs +1 -43
  85. package/dist/cjs/validators/number.cjs +1 -427
  86. package/dist/cjs/validators/object.cjs +1 -868
  87. package/dist/cjs/validators/promise.cjs +1 -115
  88. package/dist/cjs/validators/record.cjs +1 -262
  89. package/dist/cjs/validators/set.cjs +1 -203
  90. package/dist/cjs/validators/string-bool.cjs +1 -124
  91. package/dist/cjs/validators/string-formats.cjs +1 -168
  92. package/dist/cjs/validators/string.cjs +1 -12
  93. package/dist/cjs/validators/symbol.cjs +1 -62
  94. package/dist/cjs/validators/template-literal.cjs +1 -108
  95. package/dist/cjs/validators/tuple.cjs +1 -187
  96. package/dist/cjs/validators/uint8array.cjs +1 -106
  97. package/dist/cjs/validators/undefined.cjs +1 -43
  98. package/dist/cjs/validators/union.cjs +1 -191
  99. package/dist/cjs/validators/unknown.cjs +1 -40
  100. package/dist/cjs/validators/void.cjs +1 -48
  101. package/dist/cjs/validators/xor.cjs +1 -69
  102. package/dist/cli/bin.js +1 -406
  103. package/dist/cli/index.js +1 -205
  104. package/dist/codecs/index.js +1 -11
  105. package/dist/coercion/index.js +1 -579
  106. package/dist/compat/emitter.js +1 -180
  107. package/dist/compat/result.js +1 -170
  108. package/dist/errors-core.d.ts +20 -1
  109. package/dist/errors.js +1 -171
  110. package/dist/index.d.ts +248 -357
  111. package/dist/index.js +1 -1534
  112. package/dist/kernel.js +1 -409
  113. package/dist/locales/af.js +1 -106
  114. package/dist/locales/ar.js +1 -106
  115. package/dist/locales/bn.js +1 -106
  116. package/dist/locales/da.js +1 -106
  117. package/dist/locales/de.js +1 -106
  118. package/dist/locales/en.js +1 -106
  119. package/dist/locales/es-MX.js +1 -105
  120. package/dist/locales/es.js +1 -94
  121. package/dist/locales/fi.js +1 -106
  122. package/dist/locales/fr.js +1 -94
  123. package/dist/locales/hi.js +1 -106
  124. package/dist/locales/id.js +1 -106
  125. package/dist/locales/index.js +1 -29
  126. package/dist/locales/it.js +1 -106
  127. package/dist/locales/ja.js +1 -106
  128. package/dist/locales/ko.js +1 -106
  129. package/dist/locales/lazy.js +1 -177
  130. package/dist/locales/nl.js +1 -106
  131. package/dist/locales/no.js +1 -106
  132. package/dist/locales/pl.js +1 -106
  133. package/dist/locales/pt-BR.js +1 -106
  134. package/dist/locales/pt.js +1 -106
  135. package/dist/locales/ru.js +1 -106
  136. package/dist/locales/runtime.js +1 -41
  137. package/dist/locales/sv.js +1 -106
  138. package/dist/locales/sw.js +1 -106
  139. package/dist/locales/th.js +1 -106
  140. package/dist/locales/tr.js +1 -106
  141. package/dist/locales/vi.js +1 -106
  142. package/dist/locales/zh.js +1 -106
  143. package/dist/mini.d.ts +3 -3
  144. package/dist/mini.js +1 -156
  145. package/dist/pigment.js +1 -180
  146. package/dist/plugins/index.js +1 -1
  147. package/dist/registry.js +1 -34
  148. package/dist/utils/json-schema.d.ts +10 -1
  149. package/dist/v3/index.js +1 -46
  150. package/dist/v4/core/index.d.ts +28 -16
  151. package/dist/v4/core/index.js +1 -277
  152. package/dist/v4/index.js +1 -50
  153. package/dist/v4/locales/index.d.ts +4 -0
  154. package/dist/v4/locales/index.js +1 -77
  155. package/dist/v4/mini/index.js +1 -47
  156. package/dist/v4-mini/index.d.ts +1 -1
  157. package/dist/v4-mini/index.js +1 -75
  158. package/dist/validators/any.js +1 -37
  159. package/dist/validators/array.d.ts +7 -0
  160. package/dist/validators/array.js +1 -279
  161. package/dist/validators/base.d.ts +63 -8
  162. package/dist/validators/base.js +1 -868
  163. package/dist/validators/base64.js +1 -68
  164. package/dist/validators/bigint.js +1 -228
  165. package/dist/validators/boolean.js +1 -142
  166. package/dist/validators/codec.js +1 -200
  167. package/dist/validators/custom.js +1 -67
  168. package/dist/validators/date.js +1 -274
  169. package/dist/validators/discriminated-union.d.ts +2 -2
  170. package/dist/validators/discriminated-union.js +1 -123
  171. package/dist/validators/enum.js +1 -150
  172. package/dist/validators/file.js +1 -125
  173. package/dist/validators/function.js +1 -58
  174. package/dist/validators/hex.js +1 -65
  175. package/dist/validators/index.d.ts +1 -1
  176. package/dist/validators/index.js +1 -35
  177. package/dist/validators/intersection.js +1 -116
  178. package/dist/validators/json.js +1 -66
  179. package/dist/validators/lazy.js +1 -50
  180. package/dist/validators/literal.d.ts +7 -3
  181. package/dist/validators/literal.js +1 -60
  182. package/dist/validators/map.js +1 -214
  183. package/dist/validators/nan.js +1 -38
  184. package/dist/validators/never.js +1 -32
  185. package/dist/validators/null.js +1 -40
  186. package/dist/validators/number.d.ts +20 -1
  187. package/dist/validators/number.js +1 -423
  188. package/dist/validators/object.d.ts +12 -2
  189. package/dist/validators/object.js +1 -864
  190. package/dist/validators/promise.js +1 -111
  191. package/dist/validators/record.d.ts +11 -8
  192. package/dist/validators/record.js +1 -258
  193. package/dist/validators/set.js +1 -199
  194. package/dist/validators/string-bool.js +1 -120
  195. package/dist/validators/string-formats.d.ts +58 -62
  196. package/dist/validators/string-formats.js +1 -135
  197. package/dist/validators/string.d.ts +47 -10
  198. package/dist/validators/string.js +1 -4
  199. package/dist/validators/symbol.js +1 -58
  200. package/dist/validators/template-literal.js +1 -103
  201. package/dist/validators/tuple.d.ts +17 -13
  202. package/dist/validators/tuple.js +1 -183
  203. package/dist/validators/uint8array.js +1 -101
  204. package/dist/validators/undefined.js +1 -40
  205. package/dist/validators/union.js +1 -187
  206. package/dist/validators/unknown.js +1 -37
  207. package/dist/validators/void.js +1 -44
  208. package/dist/validators/xor.d.ts +2 -2
  209. package/dist/validators/xor.js +1 -66
  210. package/package.json +239 -238
  211. package/dist/chunks/errors-core-BeiFUtZM.js +0 -81
  212. package/dist/chunks/index-0R2ntSud.js +0 -508
  213. package/dist/chunks/index-BvH403Yy.js +0 -88
  214. package/dist/chunks/security-B0Pd_vSY.js +0 -35
  215. package/dist/chunks/string-BJRQod3t.js +0 -530
  216. package/dist/cjs/chunks/errors-core-DWxLFs2f.cjs +0 -83
  217. package/dist/cjs/chunks/index-BkI37108.cjs +0 -538
  218. package/dist/cjs/chunks/index-Cc3bjUMX.cjs +0 -91
  219. package/dist/cjs/chunks/security-Dc3Jh13T.cjs +0 -37
  220. package/dist/cjs/chunks/string-BKZrc4hs.cjs +0 -533
package/dist/index.js CHANGED
@@ -1,1534 +1 @@
1
- import { VLD_VALIDATOR_TYPES, VldPreprocess, VldBase, VldExactOptional, VldNullish, VldNullable, VldOptional, resolveErrorMessage } from './validators/base.js';
2
- export { VldMeta, VldBrand as ZodBranded, VldCatch as ZodCatch, VldDefault as ZodDefault, VldMeta as ZodMeta, VldRefine as ZodNonOptional, VldPipe as ZodPipe, VldPrefault as ZodPrefault, VldReadonly as ZodReadonly, VldTransform as ZodTransform } from './validators/base.js';
3
- import { globalRegistry } from './registry.js';
4
- export { registry } from './registry.js';
5
- import { V as VldString } from './chunks/string-BJRQod3t.js';
6
- import { VldNumber } from './validators/number.js';
7
- import { VldBoolean } from './validators/boolean.js';
8
- import { VldDate } from './validators/date.js';
9
- import { VldStringBool } from './validators/string-bool.js';
10
- import { VldArray } from './validators/array.js';
11
- import { VldObject } from './validators/object.js';
12
- import { VldUnion } from './validators/union.js';
13
- import { VldLiteral } from './validators/literal.js';
14
- import { VldBigInt } from './validators/bigint.js';
15
- import { VldSymbol } from './validators/symbol.js';
16
- import { VldTuple } from './validators/tuple.js';
17
- import { VldRecord } from './validators/record.js';
18
- import { VldSet } from './validators/set.js';
19
- import { VldMap } from './validators/map.js';
20
- import { VldEnum } from './validators/enum.js';
21
- import { VldIntersection } from './validators/intersection.js';
22
- import { VldAny } from './validators/any.js';
23
- import { VldUnknown } from './validators/unknown.js';
24
- import { VldVoid } from './validators/void.js';
25
- import { VldNever } from './validators/never.js';
26
- import { VldNull } from './validators/null.js';
27
- import { VldUndefined } from './validators/undefined.js';
28
- import { VldNan } from './validators/nan.js';
29
- import { VldLazy } from './validators/lazy.js';
30
- import { VldDiscriminatedUnion } from './validators/discriminated-union.js';
31
- import { VldXor } from './validators/xor.js';
32
- import { VldJson } from './validators/json.js';
33
- import { templateLiteral as templateLiteral$1 } from './validators/template-literal.js';
34
- export { VldTemplateLiteral as ZodTemplateLiteral } from './validators/template-literal.js';
35
- import { custom as custom$1 } from './validators/custom.js';
36
- export { VldCustom as ZodCustom, VldCustom as ZodSuccess } from './validators/custom.js';
37
- import { VldFile, file as file$1 } from './validators/file.js';
38
- import { functionValidator } from './validators/function.js';
39
- export { VldFunction as ZodFunction } from './validators/function.js';
40
- import { VldCodec } from './validators/codec.js';
41
- import { VldBase64 } from './validators/base64.js';
42
- import { VldHex } from './validators/hex.js';
43
- import { VldUint8Array } from './validators/uint8array.js';
44
- import { promise as promise$1 } from './validators/promise.js';
45
- export { VldPromise as ZodPromise } from './validators/promise.js';
46
- import { map as map$1 } from './compat/result.js';
47
- export { Err, Ok, ResultUtils, all, failure, flatMap, fromNullable, isErr, isOk, isResult, mapErr, match, success, tryCatch, tryCatchAsync, unwrap, unwrapOr } from './compat/result.js';
48
- import { l as localeNamespace } from './chunks/index-BvH403Yy.js';
49
- export { s as setLocaleAsync } from './chunks/index-BvH403Yy.js';
50
- import { VldCoerceBigInt, VldCoerceDate, VldCoerceBoolean, VldCoerceNumber, VldCoerceString } from './coercion/index.js';
51
- import { flattenError, prettifyError, treeifyError } from './errors.js';
52
- export { prettifyErrorColored, prettifyErrorPlain } from './errors.js';
53
- import { uuid as uuid$1, httpUrl as httpUrl$1, email as email$1, regexes as REGEXES, ksuid as ksuid$1, guid as guid$1, xid as xid$1, stringFormat as stringFormat$1, iso as iso$1, hash as hash$1, e164 as e164$1, cidrv6 as cidrv6$1, cidrv4 as cidrv4$1, mac as mac$1, ipv6 as ipv6$1, ipv4 as ipv4$1, ulid as ulid$1, cuid2 as cuid2$1, cuid as cuid$1, nanoid as nanoid$1, jwt as jwt$1, hex as hex$1, base64url as base64url$1, base64 as base64$1, emoji as emoji$1, hostname as hostname$1, uuidv7 as uuidv7$1, uuidv6 as uuidv6$1, uuidv4 as uuidv4$1 } from './validators/string-formats.js';
54
- export { VldStringFormat as ZodBase64, VldStringFormat as ZodBase64URL, VldStringFormat as ZodCIDRv4, VldStringFormat as ZodCIDRv6, VldStringFormat as ZodCUID, VldStringFormat as ZodCUID2, VldStringFormat as ZodCustomStringFormat, VldStringFormat as ZodE164, VldStringFormat as ZodEmail, VldStringFormat as ZodEmoji, VldStringFormat as ZodGUID, VldStringFormat as ZodIPv4, VldStringFormat as ZodIPv6, VldStringFormat as ZodISODate, VldStringFormat as ZodISODateTime, VldStringFormat as ZodISODuration, VldStringFormat as ZodISOTime, VldStringFormat as ZodJWT, VldStringFormat as ZodKSUID, VldStringFormat as ZodMAC, VldStringFormat as ZodNanoID, VldStringFormat as ZodStringFormat, VldStringFormat as ZodULID, VldStringFormat as ZodURL, VldStringFormat as ZodUUID, VldStringFormat as ZodXID } from './validators/string-formats.js';
55
- export { b as base64Json, a as base64ToBytes, c as base64ToUint8Array, d as base64UrlToBytes, e as base64urlToBytes, f as bytesToUtf8, g as epochMillisToDate, h as epochSecondsToDate, i as hexLowerToBytes, j as hexToBytes, k as hexToUint8Array, l as invertCodec, m as isoDatetimeToDate, n as jsonCodec, o as jwtPayload, p as numberToBigInt, s as stringToBigInt, q as stringToBoolean, r as stringToHttpURL, t as stringToInt, u as stringToNumber, v as stringToURL, w as stringToUint8Array, x as uint8ArrayToBase64, y as uint8ArrayToBase64Url, z as uint8ArrayToHex, A as uint8ArrayToString, B as uriComponent, C as utf8ToBytes } from './chunks/index-0R2ntSud.js';
56
- export { createEmitter, createEventBus, withEmitter } from './compat/emitter.js';
57
- export { createVldKernel, definePlugin, getVldKernel, resetVldKernel, usePlugin } from './kernel.js';
58
- export { blue, bold, createTheme, cyan, dim, gray, green, grey, italic, magenta, default as pigment, red, strip, supportsColor, underline, vldTheme, white, yellow } from './pigment.js';
59
- import { V as VldError } from './chunks/errors-core-BeiFUtZM.js';
60
- export { getLocale, getMessages, getSupportedLocales, isLocaleLoaded, isLocaleSupported, registerLocale, setLocale } from './locales/runtime.js';
61
-
62
- /**
63
- * JSON Schema support for VLD validators
64
- * Provides conversion between VLD schemas and JSON Schema
65
- */
66
- /**
67
- * Convert a VLD schema to JSON Schema
68
- * @param schema The VLD schema to convert
69
- * @param options Conversion options
70
- * @returns JSON Schema definition
71
- */
72
- function toJSONSchema(schema, options = {}) {
73
- const normalizedOptions = normalizeOptions(options);
74
- const result = normalizeForTarget(schemaToJSONSchema(schema, normalizedOptions), normalizedOptions);
75
- const target = normalizedOptions.target || 'draft-07';
76
- if (target === 'draft-04') {
77
- result.$schema ?? (result.$schema = 'http://json-schema.org/draft-04/schema#');
78
- }
79
- else if (target === 'draft-07') {
80
- result.$schema ?? (result.$schema = 'http://json-schema.org/draft-07/schema#');
81
- }
82
- else if (target === 'draft-2019-09') {
83
- result.$schema ?? (result.$schema = 'https://json-schema.org/draft/2019-09/schema');
84
- }
85
- else if (target === 'draft-2020-12') {
86
- result.$schema ?? (result.$schema = 'https://json-schema.org/draft/2020-12/schema');
87
- }
88
- return result;
89
- }
90
- /**
91
- * Convert a JSON Schema to a VLD schema
92
- * @param json The JSON Schema definition
93
- * @returns A VLD schema
94
- */
95
- function fromJSONSchema(json) {
96
- return jsonSchemaToVLD(json);
97
- }
98
- function normalizeOptions(options) {
99
- const target = options.target;
100
- if (target === 'draft-4') {
101
- return { ...options, target: 'draft-04' };
102
- }
103
- if (target === 'draft-7') {
104
- return { ...options, target: 'draft-07' };
105
- }
106
- return options;
107
- }
108
- function normalizeForTarget(definition, options) {
109
- const target = options.target || 'draft-07';
110
- const result = { ...definition };
111
- if (Array.isArray(result.items)) {
112
- const tupleItems = result.items.map((item) => normalizeForTarget(item, options));
113
- if (target === 'draft-2020-12' || target === 'draft-2019-09') {
114
- result.prefixItems = tupleItems;
115
- result.items = false;
116
- }
117
- else {
118
- result.items = tupleItems;
119
- }
120
- }
121
- else if (result.items && typeof result.items === 'object') {
122
- result.items = normalizeForTarget(result.items, options);
123
- }
124
- if (result.prefixItems) {
125
- result.prefixItems = result.prefixItems.map((item) => normalizeForTarget(item, options));
126
- }
127
- if (result.properties) {
128
- result.properties = Object.fromEntries(Object.entries(result.properties).map(([key, value]) => [key, normalizeForTarget(value, options)]));
129
- }
130
- if (result.additionalProperties && typeof result.additionalProperties === 'object') {
131
- result.additionalProperties = normalizeForTarget(result.additionalProperties, options);
132
- }
133
- for (const key of ['anyOf', 'allOf', 'oneOf']) {
134
- if (result[key]) {
135
- result[key] = result[key].map((item) => normalizeForTarget(item, options));
136
- }
137
- }
138
- if (result.not && typeof result.not === 'object') {
139
- result.not = normalizeForTarget(result.not, options);
140
- }
141
- if (target === 'openapi-3.0') {
142
- normalizeOpenAPI30(result);
143
- }
144
- return result;
145
- }
146
- function normalizeOpenAPI30(definition) {
147
- if (Array.isArray(definition.type) && definition.type.includes('null')) {
148
- const nonNullTypes = definition.type.filter((type) => type !== 'null');
149
- definition.nullable = true;
150
- if (nonNullTypes.length === 1) {
151
- const nonNullType = nonNullTypes[0];
152
- if (nonNullType !== undefined) {
153
- definition.type = nonNullType;
154
- }
155
- else {
156
- delete definition.type;
157
- }
158
- }
159
- else if (nonNullTypes.length > 1) {
160
- definition.type = nonNullTypes;
161
- }
162
- else {
163
- delete definition.type;
164
- }
165
- }
166
- if (typeof definition.exclusiveMinimum === 'number') {
167
- definition.minimum ?? (definition.minimum = definition.exclusiveMinimum);
168
- definition.exclusiveMinimum = true;
169
- }
170
- if (typeof definition.exclusiveMaximum === 'number') {
171
- definition.maximum ?? (definition.maximum = definition.exclusiveMaximum);
172
- definition.exclusiveMaximum = true;
173
- }
174
- }
175
- /**
176
- * Internal function to convert VLD schema to JSON Schema
177
- */
178
- function schemaToJSONSchema(schema, options) {
179
- const target = options.target || 'draft-07';
180
- const schemaAny = schema;
181
- const validatorType = schema.validatorType;
182
- // Handle primitives
183
- if (schema.constructor.name === 'VldString' || validatorType === VLD_VALIDATOR_TYPES.STRING) {
184
- return withMetadata(schema, buildStringSchema(target, schema), options);
185
- }
186
- if (schema.constructor.name === 'VldNumber' || validatorType === VLD_VALIDATOR_TYPES.NUMBER) {
187
- return withMetadata(schema, buildNumberSchema(schema), options);
188
- }
189
- if (schema.constructor.name === 'VldBoolean' || validatorType === VLD_VALIDATOR_TYPES.BOOLEAN) {
190
- return withMetadata(schema, { type: 'boolean' }, options);
191
- }
192
- if (schema.constructor.name === 'VldBigInt' || validatorType === VLD_VALIDATOR_TYPES.BIGINT) {
193
- return withMetadata(schema, buildBigIntSchema(schema), options);
194
- }
195
- if (schema.constructor.name === 'VldDate' || validatorType === VLD_VALIDATOR_TYPES.DATE) {
196
- return withMetadata(schema, buildDateSchema(schema), options);
197
- }
198
- if (schema.constructor.name === 'VldArray' || validatorType === VLD_VALIDATOR_TYPES.ARRAY) {
199
- return withMetadata(schema, buildArraySchema(schema, options), options);
200
- }
201
- if (schema.constructor.name === 'VldObject' || validatorType === VLD_VALIDATOR_TYPES.OBJECT) {
202
- return withMetadata(schema, buildObjectSchema(schema, options), options);
203
- }
204
- // Handle union types
205
- if (schema.constructor.name === 'VldUnion') {
206
- return withMetadata(schema, buildUnionSchema(schema, options), options);
207
- }
208
- // Handle literal types
209
- if (schema.constructor.name === 'VldLiteral') {
210
- return withMetadata(schema, buildLiteralSchema(schema), options);
211
- }
212
- if (schema.constructor.name === 'VldEnum') {
213
- return withMetadata(schema, buildEnumSchema(schema), options);
214
- }
215
- if (schema.constructor.name === 'VldSet' || validatorType === VLD_VALIDATOR_TYPES.SET) {
216
- return withMetadata(schema, buildSetSchema(schema, options), options);
217
- }
218
- if (schema.constructor.name === 'VldMap' || validatorType === VLD_VALIDATOR_TYPES.MAP) {
219
- return withMetadata(schema, buildMapSchema(schema, options), options);
220
- }
221
- if (schema.constructor.name === 'VldRecord' || validatorType === VLD_VALIDATOR_TYPES.RECORD) {
222
- return withMetadata(schema, buildRecordSchema(schema, options), options);
223
- }
224
- if (schema.constructor.name === 'VldTuple' || validatorType === VLD_VALIDATOR_TYPES.TUPLE) {
225
- return withMetadata(schema, buildTupleSchema(schema, options), options);
226
- }
227
- if (schema.constructor.name === 'VldIntersection') {
228
- return withMetadata(schema, buildIntersectionSchema(schema, options), options);
229
- }
230
- if (schema.constructor.name === 'VldOptional') {
231
- return withMetadata(schema, buildOptionalSchema(schema, options), options);
232
- }
233
- if (schema.constructor.name === 'VldNullable') {
234
- return withMetadata(schema, buildNullableSchema(schema, options), options);
235
- }
236
- if (schema.constructor.name === 'VldNullish') {
237
- return withMetadata(schema, buildNullishSchema(schema, options), options);
238
- }
239
- if (schema.constructor.name === 'VldExactOptional') {
240
- return withMetadata(schema, buildExactOptionalSchema(schema, options), options);
241
- }
242
- if (schema.constructor.name === 'VldLazy') {
243
- return withMetadata(schema, { type: 'object' }, options); // Placeholder for recursive schemas
244
- }
245
- if (schema.constructor.name === 'VldJson') {
246
- return withMetadata(schema, {}, options); // Any JSON
247
- }
248
- if (schema.constructor.name === 'VldAny') {
249
- return withMetadata(schema, {}, options); // JSON Schema true
250
- }
251
- if (schema.constructor.name === 'VldUnknown') {
252
- return withMetadata(schema, {}, options); // JSON Schema true
253
- }
254
- if (schema.constructor.name === 'VldNever') {
255
- return withMetadata(schema, { not: {} }, options); // JSON Schema false
256
- }
257
- if (schema.constructor.name === 'VldNull') {
258
- return withMetadata(schema, { type: 'null' }, options);
259
- }
260
- if (schema.constructor.name === 'VldUndefined') {
261
- return withMetadata(schema, { not: {} }, options); // Undefined can't be represented in JSON Schema
262
- }
263
- if (schema.constructor.name === 'VldNan') {
264
- return withMetadata(schema, { type: 'number', not: {} }, options); // NaN is a number type constraint
265
- }
266
- if (schema.constructor.name === 'VldVoid') {
267
- return withMetadata(schema, { not: {} }, options); // Void/undefined can't be represented
268
- }
269
- // Handle branded types - unwrap and continue
270
- if (schema.constructor.name === 'VldBrand') {
271
- return withMetadata(schema, schemaToJSONSchema(schemaAny.baseValidator, options), options);
272
- }
273
- // Handle readonly types
274
- if (schema.constructor.name === 'VldReadonly') {
275
- return withMetadata(schema, schemaToJSONSchema(schemaAny.baseValidator, options), options);
276
- }
277
- // Handle transform types
278
- if (schema.constructor.name === 'VldTransform') {
279
- return schemaToJSONSchema(schema._inner, options);
280
- }
281
- // Handle meta types - unwrap metadata
282
- if (schema.constructor.name === 'VldMeta') {
283
- const result = schemaToJSONSchema(schemaAny.baseValidator, options);
284
- return withMetadata(schema, result, options);
285
- }
286
- // Handle refine/superRefine types
287
- if (schema.constructor.name === 'VldRefine' || schema.constructor.name === 'VldSuperRefine') {
288
- return withMetadata(schema, schemaToJSONSchema(unwrapInner(schemaAny), options), options);
289
- }
290
- // Handle pipe types
291
- if (schema.constructor.name === 'VldPipe') {
292
- return withMetadata(schema, schemaToJSONSchema(schemaAny._next || schemaAny.second, options), options);
293
- }
294
- // Handle default/catch types
295
- if (schema.constructor.name === 'VldDefault' || schema.constructor.name === 'VldCatch') {
296
- return withMetadata(schema, schemaToJSONSchema(unwrapInner(schemaAny), options), options);
297
- }
298
- // Handle preprocess types
299
- if (schema.constructor.name === 'VldPreprocess') {
300
- return withMetadata(schema, schemaToJSONSchema(schemaAny._schema, options), options);
301
- }
302
- // Handle string format validators
303
- if (schema.constructor.name === 'VldStringFormat') {
304
- const formatSchema = schema;
305
- return withMetadata(schema, { type: 'string', format: formatSchema._format }, options);
306
- }
307
- // Fallback for unknown types
308
- return withMetadata(schema, {}, options);
309
- }
310
- function unwrapInner(schema) {
311
- if (typeof schema.unwrap === 'function') {
312
- return schema.unwrap();
313
- }
314
- return schema._inner || schema._baseValidator || schema.baseValidator || schema.valueValidator;
315
- }
316
- function getMetadata(schema) {
317
- const registered = globalRegistry.get(schema);
318
- const schemaAny = schema;
319
- const local = typeof schemaAny.getMeta === 'function' ? schemaAny.getMeta() : undefined;
320
- return registered || local ? { ...(local || {}), ...(registered || {}) } : undefined;
321
- }
322
- function withMetadata(schema, definition, options) {
323
- if (options.includeMetadata === false) {
324
- return definition;
325
- }
326
- const metadata = getMetadata(schema);
327
- if (!metadata) {
328
- return definition;
329
- }
330
- const result = { ...definition };
331
- if (metadata.id)
332
- result.$id = metadata.id;
333
- if (metadata.title)
334
- result.title = metadata.title;
335
- if (metadata.description)
336
- result.description = metadata.description;
337
- if (metadata.examples && options.includeExamples !== false)
338
- result.examples = metadata.examples;
339
- if (metadata.default !== undefined)
340
- result.default = metadata.default;
341
- if (metadata.deprecated)
342
- result.deprecated = true;
343
- if (metadata.readOnly)
344
- result.readOnly = true;
345
- if (metadata.writeOnly)
346
- result.writeOnly = true;
347
- return result;
348
- }
349
- /**
350
- * Build string JSON Schema
351
- */
352
- function buildStringSchema(_target, schema) {
353
- const hints = schema?.config?.jsonSchema || {};
354
- const result = { type: 'string' };
355
- if (hints.exactLength !== undefined) {
356
- result.minLength = hints.exactLength;
357
- result.maxLength = hints.exactLength;
358
- }
359
- else {
360
- if (hints.minLength !== undefined)
361
- result.minLength = hints.minLength;
362
- if (hints.maxLength !== undefined)
363
- result.maxLength = hints.maxLength;
364
- }
365
- if (hints.format)
366
- result.format = hints.format;
367
- if (hints.pattern)
368
- result.pattern = hints.pattern;
369
- return result;
370
- }
371
- /**
372
- * Build number JSON Schema from VLD number schema
373
- */
374
- function buildNumberSchema(schema, _target) {
375
- const config = schema.config || {};
376
- const hints = config.jsonSchema || {};
377
- const checks = config.checks || [];
378
- const result = { type: hints.type || 'number' };
379
- if (hints.minimum !== undefined)
380
- result.minimum = hints.minimum;
381
- if (hints.maximum !== undefined)
382
- result.maximum = hints.maximum;
383
- if (hints.exclusiveMinimum !== undefined)
384
- result.exclusiveMinimum = hints.exclusiveMinimum;
385
- if (hints.exclusiveMaximum !== undefined)
386
- result.exclusiveMaximum = hints.exclusiveMaximum;
387
- if (hints.multipleOf !== undefined)
388
- result.multipleOf = hints.multipleOf;
389
- if (Object.keys(hints).length > 0) {
390
- return result;
391
- }
392
- for (const check of checks) {
393
- // Try to extract constraints from closures
394
- const checkStr = check.toString();
395
- if (checkStr.includes('>=') || checkStr.includes('min')) {
396
- result.minimum = 0; // Default, actual value is in closure
397
- }
398
- if (checkStr.includes('<=') || checkStr.includes('max')) {
399
- result.maximum = 0; // Default, actual value is in closure
400
- }
401
- if (checkStr.includes('isInteger') || checkStr.includes('int')) {
402
- result.type = 'integer';
403
- }
404
- if (checkStr.includes('isSafeInteger')) {
405
- result.type = 'integer';
406
- }
407
- if (checkStr.includes('Number.isFinite')) ;
408
- }
409
- return result;
410
- }
411
- function bigintToSafeNumber(value) {
412
- const asNumber = Number(value);
413
- if (!Number.isSafeInteger(asNumber)) {
414
- return undefined;
415
- }
416
- return BigInt(asNumber) === value ? asNumber : undefined;
417
- }
418
- function applyBigIntBound(result, numericKey, extensionKey, value) {
419
- if (value === undefined) {
420
- return;
421
- }
422
- result[extensionKey] = value.toString();
423
- const safeNumber = bigintToSafeNumber(value);
424
- if (safeNumber !== undefined) {
425
- result[numericKey] = safeNumber;
426
- }
427
- }
428
- function buildBigIntSchema(schema) {
429
- const hints = schema.jsonSchema || schema.config?.jsonSchema || {};
430
- const result = { type: 'integer' };
431
- applyBigIntBound(result, 'minimum', 'x-vld-minimum', hints.minimum);
432
- applyBigIntBound(result, 'maximum', 'x-vld-maximum', hints.maximum);
433
- applyBigIntBound(result, 'exclusiveMinimum', 'x-vld-exclusiveMinimum', hints.exclusiveMinimum);
434
- applyBigIntBound(result, 'exclusiveMaximum', 'x-vld-exclusiveMaximum', hints.exclusiveMaximum);
435
- return result;
436
- }
437
- function buildDateSchema(schema) {
438
- const hints = schema.jsonSchema || schema.config?.jsonSchema || {};
439
- const result = {
440
- type: 'string',
441
- format: 'date-time'
442
- };
443
- if (hints.formatMinimum)
444
- result.formatMinimum = hints.formatMinimum;
445
- if (hints.formatMaximum)
446
- result.formatMaximum = hints.formatMaximum;
447
- if (hints.formatExclusiveMinimum)
448
- result.formatExclusiveMinimum = hints.formatExclusiveMinimum;
449
- if (hints.formatExclusiveMaximum)
450
- result.formatExclusiveMaximum = hints.formatExclusiveMaximum;
451
- return result;
452
- }
453
- /**
454
- * Build array JSON Schema
455
- */
456
- function buildArraySchema(schema, options) {
457
- const inner = schema._item || schema._inner || schema.config?.itemValidator;
458
- const result = { type: 'array' };
459
- if (inner) {
460
- result.items = schemaToJSONSchema(inner, options);
461
- }
462
- if (schema.config?.exactLength !== undefined) {
463
- result.minItems = schema.config.exactLength;
464
- result.maxItems = schema.config.exactLength;
465
- }
466
- else {
467
- if (schema.config?.minLength !== undefined)
468
- result.minItems = schema.config.minLength;
469
- if (schema.config?.maxLength !== undefined)
470
- result.maxItems = schema.config.maxLength;
471
- }
472
- if (schema.config?.unique)
473
- result.uniqueItems = true;
474
- return result;
475
- }
476
- /**
477
- * Build object JSON Schema
478
- */
479
- function buildObjectSchema(schema, options) {
480
- const shape = schema._shape || schema.shape || schema.config?.shape;
481
- if (!shape)
482
- return { type: 'object' };
483
- const properties = {};
484
- const required = [];
485
- for (const [key, value] of Object.entries(shape)) {
486
- const child = value;
487
- properties[key] = schemaToJSONSchema(child, options);
488
- // VLD objects require all keys by default
489
- if (!isOptionalLike(child)) {
490
- required.push(key);
491
- }
492
- }
493
- const result = {
494
- type: 'object',
495
- properties
496
- };
497
- if (required.length > 0) {
498
- result.required = required;
499
- }
500
- // Handle passthrough mode
501
- if (schema._passthrough || schema._loose || schema.config?.passthrough) {
502
- result.additionalProperties = true;
503
- }
504
- else if (schema._strict || schema.config?.strict) {
505
- result.additionalProperties = false;
506
- }
507
- else if (schema.config?.catchall) {
508
- result.additionalProperties = schemaToJSONSchema(schema.config.catchall, options);
509
- }
510
- return result;
511
- }
512
- function isOptionalLike(schema) {
513
- const name = schema.constructor.name;
514
- return (name === 'VldOptional' ||
515
- name === 'VldNullish' ||
516
- name === 'VldExactOptional' ||
517
- schema.validatorType === VLD_VALIDATOR_TYPES.OPTIONAL ||
518
- schema.validatorType === VLD_VALIDATOR_TYPES.NULLISH ||
519
- schema.validatorType === VLD_VALIDATOR_TYPES.EXACT_OPTIONAL);
520
- }
521
- /**
522
- * Build union JSON Schema
523
- */
524
- function buildUnionSchema(schema, options) {
525
- const validators = schema._validators || schema._options || schema.validators || [];
526
- return {
527
- anyOf: validators.map((v) => schemaToJSONSchema(v, options))
528
- };
529
- }
530
- /**
531
- * Build literal JSON Schema
532
- */
533
- function buildLiteralSchema(schema) {
534
- const value = schema._literal ?? schema.literal ?? schema._value ?? schema.value;
535
- if (value === null)
536
- return { type: 'null' };
537
- if (typeof value === 'string')
538
- return { type: 'string', const: value };
539
- if (typeof value === 'number')
540
- return { type: 'number', const: value };
541
- if (typeof value === 'boolean')
542
- return { type: 'boolean', const: value };
543
- return { const: value };
544
- }
545
- /**
546
- * Build enum JSON Schema
547
- */
548
- function buildEnumSchema(schema) {
549
- const values = schema._values || schema.values;
550
- if (Array.isArray(values)) {
551
- return { enum: [...values] };
552
- }
553
- return {};
554
- }
555
- /**
556
- * Build record JSON Schema
557
- */
558
- function buildRecordSchema(schema, options) {
559
- const valueValidator = schema.valueSchema || schema._value || schema._inner || schema.valueValidator;
560
- if (valueValidator) {
561
- return {
562
- type: 'object',
563
- additionalProperties: schemaToJSONSchema(valueValidator, options)
564
- };
565
- }
566
- return { type: 'object' };
567
- }
568
- /**
569
- * Build Set JSON Schema as the JSON-compatible array representation.
570
- */
571
- function buildSetSchema(schema, options) {
572
- const itemValidator = schema.itemSchema || schema.itemValidator || schema._item || schema._inner;
573
- const result = {
574
- type: 'array',
575
- uniqueItems: true,
576
- 'x-vld-type': 'set'
577
- };
578
- if (itemValidator) {
579
- result.items = schemaToJSONSchema(itemValidator, options);
580
- }
581
- return result;
582
- }
583
- /**
584
- * Build Map JSON Schema as an array of key/value pairs.
585
- */
586
- function buildMapSchema(schema, options) {
587
- const keyValidator = schema.keySchema || schema.keyValidator || schema._key;
588
- const valueValidator = schema.valueSchema || schema.valueValidator || schema._value;
589
- const keySchema = keyValidator ? schemaToJSONSchema(keyValidator, options) : {};
590
- const valueSchema = valueValidator ? schemaToJSONSchema(valueValidator, options) : {};
591
- return {
592
- type: 'array',
593
- 'x-vld-type': 'map',
594
- items: {
595
- type: 'array',
596
- items: [keySchema, valueSchema],
597
- minItems: 2,
598
- maxItems: 2
599
- }
600
- };
601
- }
602
- /**
603
- * Build tuple JSON Schema
604
- */
605
- function buildTupleSchema(schema, options) {
606
- const items = schema.items || schema._items || schema.validators;
607
- if (!items || !Array.isArray(items)) {
608
- return { type: 'array' };
609
- }
610
- return {
611
- type: 'array',
612
- items: items.map((item) => schemaToJSONSchema(item, options)),
613
- minItems: items.length,
614
- maxItems: items.length
615
- };
616
- }
617
- /**
618
- * Build intersection JSON Schema
619
- */
620
- function buildIntersectionSchema(schema, options) {
621
- const first = schema._first || schema.first;
622
- const second = schema._second || schema.second;
623
- const schemas = [];
624
- if (first)
625
- schemas.push(schemaToJSONSchema(first, options));
626
- if (second)
627
- schemas.push(schemaToJSONSchema(second, options));
628
- if (schemas.length === 0)
629
- return {};
630
- if (schemas.length === 1)
631
- return schemas[0] ?? {};
632
- return { allOf: schemas };
633
- }
634
- /**
635
- * Build optional JSON Schema
636
- */
637
- function buildOptionalSchema(schema, options) {
638
- const inner = unwrapInner(schema);
639
- if (!inner)
640
- return {};
641
- const result = schemaToJSONSchema(inner, options);
642
- // Remove from required array - but we don't track required here
643
- return result;
644
- }
645
- /**
646
- * Build nullable JSON Schema
647
- */
648
- function buildNullableSchema(schema, options) {
649
- const inner = unwrapInner(schema);
650
- if (!inner)
651
- return { type: 'null' };
652
- const result = schemaToJSONSchema(inner, options);
653
- if (typeof result.type === 'string') {
654
- return { type: [result.type, 'null'] };
655
- }
656
- else if (Array.isArray(result.type)) {
657
- result.type.push('null');
658
- return result;
659
- }
660
- return {
661
- anyOf: [result, { type: 'null' }]
662
- };
663
- }
664
- /**
665
- * Build nullish JSON Schema
666
- */
667
- function buildNullishSchema(schema, options) {
668
- const inner = unwrapInner(schema);
669
- if (!inner)
670
- return {};
671
- const result = schemaToJSONSchema(inner, options);
672
- if (typeof result.type === 'string') {
673
- return { ...result, type: [result.type, 'null'] };
674
- }
675
- return result;
676
- }
677
- /**
678
- * Build exactOptional JSON Schema
679
- */
680
- function buildExactOptionalSchema(schema, options) {
681
- const inner = unwrapInner(schema);
682
- if (!inner)
683
- return {};
684
- return schemaToJSONSchema(inner, options);
685
- }
686
- /**
687
- * Internal function to convert JSON Schema to VLD schema
688
- */
689
- function jsonSchemaToVLD(json) {
690
- return applyJSONSchemaMetadata(jsonSchemaToVLDInner(json), json);
691
- }
692
- function jsonSchemaToVLDInner(json) {
693
- // Handle $ref
694
- if (json.$ref) {
695
- // For now, return any - full $ref handling requires registry
696
- return VldAny.create();
697
- }
698
- // Handle anyOf/oneOf (union)
699
- if (json.anyOf || json.oneOf) {
700
- const options = (json.anyOf || json.oneOf)
701
- .map((s) => jsonSchemaToVLD(s))
702
- .filter(Boolean);
703
- if (options.length > 0) {
704
- return VldUnion.create(...options);
705
- }
706
- }
707
- // Handle allOf (intersection)
708
- if (json.allOf) {
709
- // For intersection, we'd need VldIntersection
710
- const firstSchema = json.allOf[0];
711
- if (firstSchema === undefined) {
712
- return VldAny.create();
713
- }
714
- const first = jsonSchemaToVLD(firstSchema);
715
- if (json.allOf.length > 1) {
716
- const second = jsonSchemaToVLD({ allOf: json.allOf.slice(1) });
717
- return VldIntersection.create(first, second);
718
- }
719
- return first;
720
- }
721
- // Handle not
722
- if (json.not) {
723
- // For negation, we need special handling
724
- return VldAny.create();
725
- }
726
- // Handle const
727
- if (json.const !== undefined) {
728
- return VldLiteral.create(json.const);
729
- }
730
- // Handle enum
731
- if (json.enum) {
732
- return VldEnum.create(json.enum);
733
- }
734
- // Handle type
735
- const type = json.nullable && typeof json.type === 'string'
736
- ? [json.type, 'null']
737
- : json.type;
738
- if (type === 'string' || type === undefined) {
739
- let s = VldString.create();
740
- if (json.minLength !== undefined)
741
- s = s.min(json.minLength);
742
- if (json.maxLength !== undefined)
743
- s = s.max(json.maxLength);
744
- if (json.pattern)
745
- s = s.regex(new RegExp(json.pattern));
746
- if (json.format) {
747
- // Map JSON Schema formats to VLD validators
748
- switch (json.format) {
749
- case 'date-time':
750
- case 'date':
751
- case 'time':
752
- // Would need DateTime validator
753
- break;
754
- case 'email':
755
- return email$1();
756
- case 'uri':
757
- case 'uri-reference':
758
- return httpUrl$1();
759
- case 'uuid':
760
- return uuid$1();
761
- }
762
- }
763
- return s;
764
- }
765
- if (type === 'number' || type === 'integer') {
766
- let n = VldNumber.create();
767
- if (type === 'integer')
768
- n = n.int();
769
- if (json.minimum !== undefined)
770
- n = n.min(json.minimum);
771
- if (json.maximum !== undefined)
772
- n = n.max(json.maximum);
773
- if (typeof json.exclusiveMinimum === 'number')
774
- n = n.gt(json.exclusiveMinimum);
775
- if (typeof json.exclusiveMaximum === 'number')
776
- n = n.lt(json.exclusiveMaximum);
777
- if (json.exclusiveMinimum === true && json.minimum !== undefined)
778
- n = n.gt(json.minimum);
779
- if (json.exclusiveMaximum === true && json.maximum !== undefined)
780
- n = n.lt(json.maximum);
781
- if (json.multipleOf !== undefined)
782
- n = n.multipleOf(json.multipleOf);
783
- return n;
784
- }
785
- if (type === 'boolean') {
786
- return VldBoolean.create();
787
- }
788
- if (type === 'array') {
789
- if (json.prefixItems && json.prefixItems.length > 0) {
790
- const validators = json.prefixItems.map((item) => jsonSchemaToVLD(item));
791
- return VldTuple.create(...validators);
792
- }
793
- if (Array.isArray(json.items)) {
794
- const validators = json.items.map((item) => jsonSchemaToVLD(item));
795
- return VldTuple.create(...validators);
796
- }
797
- if (json.items && !Array.isArray(json.items)) {
798
- return VldArray.create(jsonSchemaToVLD(json.items));
799
- }
800
- return VldArray.create(VldAny.create());
801
- }
802
- if (type === 'object') {
803
- if (json.properties) {
804
- const shape = {};
805
- const required = new Set(json.required || []);
806
- for (const [key, propSchema] of Object.entries(json.properties)) {
807
- const fieldSchema = jsonSchemaToVLD(propSchema);
808
- shape[key] = required.has(key) ? fieldSchema : fieldSchema.optional();
809
- }
810
- let obj = VldObject.create(shape);
811
- if (json.additionalProperties === false) {
812
- obj = obj.strict();
813
- }
814
- else if (json.additionalProperties === true) {
815
- obj = obj.passthrough();
816
- }
817
- else if (json.additionalProperties) {
818
- // additionalProperties is a schema
819
- const valueSchema = jsonSchemaToVLD(json.additionalProperties);
820
- return VldRecord.create(valueSchema);
821
- }
822
- return obj;
823
- }
824
- // Empty object schema
825
- return VldObject.create({});
826
- }
827
- if (type === 'null') {
828
- return VldNull.create();
829
- }
830
- if (Array.isArray(type)) {
831
- // Union of types
832
- const options = type.map((t) => {
833
- return jsonSchemaToVLD({ ...json, type: t, nullable: false });
834
- });
835
- if (options.length > 0) {
836
- return VldUnion.create(...options);
837
- }
838
- }
839
- // Fallback to any
840
- return VldAny.create();
841
- }
842
- function applyJSONSchemaMetadata(schema, json) {
843
- const metadata = {};
844
- if (json.$id)
845
- metadata.id = json.$id;
846
- if (json.title)
847
- metadata.title = json.title;
848
- if (json.description)
849
- metadata.description = json.description;
850
- if (json.examples)
851
- metadata.examples = json.examples;
852
- if (json.default !== undefined)
853
- metadata.default = json.default;
854
- if (json.deprecated)
855
- metadata.deprecated = true;
856
- if (json.readOnly)
857
- metadata.readOnly = true;
858
- if (json.writeOnly)
859
- metadata.writeOnly = true;
860
- return Object.keys(metadata).length > 0
861
- ? schema.meta(metadata)
862
- : schema;
863
- }
864
-
865
- /**
866
- * VLD Logger
867
- *
868
- * This module provides a debug logging system for VLD,
869
- * compatible with @oxog/log when available.
870
- */
871
- /**
872
- * Log level priorities (lower = more verbose)
873
- */
874
- const LOG_LEVEL_PRIORITY = {
875
- debug: 0,
876
- info: 1,
877
- warn: 2,
878
- error: 3,
879
- silent: 4
880
- };
881
- /**
882
- * ANSI color codes for terminal output
883
- */
884
- const COLORS = {
885
- reset: '\x1b[0m',
886
- dim: '\x1b[2m',
887
- red: '\x1b[31m',
888
- yellow: '\x1b[33m',
889
- blue: '\x1b[34m',
890
- cyan: '\x1b[36m',
891
- gray: '\x1b[90m'
892
- };
893
- /**
894
- * Level colors
895
- */
896
- const LEVEL_COLORS = {
897
- debug: COLORS.gray,
898
- info: COLORS.blue,
899
- warn: COLORS.yellow,
900
- error: COLORS.red
901
- };
902
- /**
903
- * Level labels
904
- */
905
- const LEVEL_LABELS = {
906
- debug: 'DEBUG',
907
- info: 'INFO ',
908
- warn: 'WARN ',
909
- error: 'ERROR'
910
- };
911
- /**
912
- * Default log handler
913
- */
914
- function createDefaultHandler(options) {
915
- const colored = options.colored ?? true;
916
- const timestamps = options.timestamps ?? true;
917
- return (entry) => {
918
- const parts = [];
919
- // Timestamp
920
- if (timestamps) {
921
- const time = entry.timestamp.toISOString().slice(11, 23);
922
- parts.push(colored ? `${COLORS.dim}${time}${COLORS.reset}` : time);
923
- }
924
- // Level
925
- const levelLabel = LEVEL_LABELS[entry.level];
926
- const levelColor = LEVEL_COLORS[entry.level];
927
- parts.push(colored ? `${levelColor}${levelLabel}${COLORS.reset}` : levelLabel);
928
- // Name
929
- parts.push(colored ? `${COLORS.cyan}[${entry.name}]${COLORS.reset}` : `[${entry.name}]`);
930
- // Message
931
- parts.push(entry.message);
932
- // Output
933
- const output = parts.join(' ');
934
- // Use appropriate console method
935
- switch (entry.level) {
936
- case 'debug':
937
- console.debug(output, entry.data !== undefined ? entry.data : '');
938
- break;
939
- case 'info':
940
- console.info(output, entry.data !== undefined ? entry.data : '');
941
- break;
942
- case 'warn':
943
- console.warn(output, entry.data !== undefined ? entry.data : '');
944
- break;
945
- case 'error':
946
- console.error(output, entry.data !== undefined ? entry.data : '');
947
- break;
948
- }
949
- };
950
- }
951
- /**
952
- * Create a logger instance
953
- */
954
- function createLogger(options = {}) {
955
- const name = options.name ?? 'vld';
956
- let level = options.level ?? 'warn';
957
- const handler = options.handler ?? createDefaultHandler(options);
958
- const log = (logLevel, message, data) => {
959
- if (LOG_LEVEL_PRIORITY[logLevel] < LOG_LEVEL_PRIORITY[level]) {
960
- return;
961
- }
962
- const entry = {
963
- level: logLevel,
964
- message,
965
- data,
966
- timestamp: new Date(),
967
- name
968
- };
969
- handler(entry);
970
- };
971
- const logger = {
972
- debug: (message, data) => log('debug', message, data),
973
- info: (message, data) => log('info', message, data),
974
- warn: (message, data) => log('warn', message, data),
975
- error: (message, data) => log('error', message, data),
976
- isLevelEnabled: (checkLevel) => LOG_LEVEL_PRIORITY[checkLevel] >= LOG_LEVEL_PRIORITY[level],
977
- setLevel: (newLevel) => {
978
- level = newLevel;
979
- },
980
- getLevel: () => level,
981
- child: (childName) => createLogger({
982
- ...options,
983
- name: `${name}:${childName}`
984
- })
985
- };
986
- return logger;
987
- }
988
- // ============================================
989
- // Global Logger Management
990
- // ============================================
991
- let globalLogger = null;
992
- /**
993
- * Initialize the global VLD logger
994
- */
995
- function initLogger(options) {
996
- globalLogger = createLogger({
997
- name: 'vld',
998
- ...options
999
- });
1000
- return globalLogger;
1001
- }
1002
- /**
1003
- * Get the global VLD logger
1004
- * Returns null if not initialized
1005
- */
1006
- function getLogger() {
1007
- return globalLogger;
1008
- }
1009
- /**
1010
- * Set log level for the global logger
1011
- */
1012
- function setLogLevel(level) {
1013
- if (globalLogger) {
1014
- globalLogger.setLevel(level);
1015
- }
1016
- }
1017
- /**
1018
- * Enable debug mode for VLD
1019
- */
1020
- function enableDebug() {
1021
- if (!globalLogger) {
1022
- initLogger({ level: 'debug' });
1023
- }
1024
- else {
1025
- globalLogger.setLevel('debug');
1026
- }
1027
- }
1028
- /**
1029
- * Disable all VLD logging
1030
- */
1031
- function disableLogging() {
1032
- if (globalLogger) {
1033
- globalLogger.setLevel('silent');
1034
- }
1035
- }
1036
- /**
1037
- * Create a no-op logger for testing
1038
- */
1039
- function createNoOpLogger() {
1040
- return createLogger({ level: 'silent' });
1041
- }
1042
-
1043
- /**
1044
- * VLD - Fast, Type-Safe Validation Library
1045
- * Zero dependencies, blazing fast performance
1046
- *
1047
- * This is the new modular implementation with:
1048
- * - Immutable validators (no memory leaks)
1049
- * - Secure deepMerge (no prototype pollution)
1050
- * - TypeScript strict mode support
1051
- * - Better performance through pooling and memoization
1052
- * - Plugin system for extensibility
1053
- * - Event system for validation lifecycle hooks
1054
- * - Result pattern for functional error handling
1055
- * - Colored console output for better debugging
1056
- * - Debug logging system
1057
- */
1058
- // Import base class
1059
- let globalConfig = {};
1060
- let globalErrorMap;
1061
- function configure(config) {
1062
- if (config === undefined) {
1063
- return { ...globalConfig };
1064
- }
1065
- globalConfig = { ...globalConfig, ...config };
1066
- if ('customError' in config) {
1067
- globalErrorMap = config.customError;
1068
- }
1069
- else if ('errorMap' in config) {
1070
- globalErrorMap = config.errorMap;
1071
- }
1072
- return { ...globalConfig };
1073
- }
1074
- function setGlobalErrorMap(errorMap) {
1075
- globalErrorMap = errorMap;
1076
- globalConfig = { ...globalConfig, errorMap };
1077
- }
1078
- function getGlobalErrorMap() {
1079
- return globalErrorMap;
1080
- }
1081
- function enumValuesFromNativeEnum(enumObject) {
1082
- const values = Object.keys(enumObject)
1083
- .filter(key => !/^\d+$/.test(key))
1084
- .map(key => enumObject[key])
1085
- .filter((value) => typeof value === 'string' || typeof value === 'number');
1086
- const uniqueValues = Array.from(new Set(values));
1087
- if (uniqueValues.length === 0) {
1088
- throw new Error('nativeEnum requires at least one string or number value');
1089
- }
1090
- return uniqueValues;
1091
- }
1092
- function toErrorMessage(error) {
1093
- return error instanceof Error ? error.message : String(error);
1094
- }
1095
- function addFormattedIssue(root, path, message) {
1096
- let current = root;
1097
- for (const segment of path) {
1098
- const key = String(segment);
1099
- const next = current[key];
1100
- if (!next || Array.isArray(next)) {
1101
- current[key] = { _errors: [] };
1102
- }
1103
- current = current[key];
1104
- }
1105
- current._errors.push(message);
1106
- }
1107
- function isCodec(schema) {
1108
- return schema instanceof VldCodec;
1109
- }
1110
- function messageFromRefinementParam(param) {
1111
- return param === undefined ? undefined : resolveErrorMessage(param, 'Refinement check failed');
1112
- }
1113
- function cloneSchema(schema) {
1114
- return schema;
1115
- }
1116
- function createTransform(transformer) {
1117
- return custom$1({
1118
- parse: (value) => {
1119
- const transformed = transformer(value, { addIssue: () => undefined, path: [] });
1120
- if (transformed !== null && typeof transformed === 'object' && typeof transformed.then === 'function') {
1121
- throw new Error('Use parseAsync for async transforms');
1122
- }
1123
- return transformed;
1124
- },
1125
- parseAsync: async (value) => {
1126
- const transformed = await Promise.resolve(transformer(value, { addIssue: () => undefined, path: [] }));
1127
- return transformed;
1128
- }
1129
- });
1130
- }
1131
- function createRefinement(predicate, message) {
1132
- return custom$1({
1133
- parse: (value) => {
1134
- const passed = predicate(value);
1135
- if (passed !== null && typeof passed === 'object' && typeof passed.then === 'function') {
1136
- throw new Error('Use parseAsync for async refinements');
1137
- }
1138
- if (!passed) {
1139
- throw new Error(messageFromRefinementParam(message) || 'Refinement check failed');
1140
- }
1141
- return value;
1142
- },
1143
- parseAsync: async (value) => {
1144
- if (!await predicate(value)) {
1145
- throw new Error(messageFromRefinementParam(message) || 'Refinement check failed');
1146
- }
1147
- return value;
1148
- }
1149
- });
1150
- }
1151
- function createSuperRefinement(refinement) {
1152
- return VldUnknown.create().superRefine(refinement);
1153
- }
1154
- function propertyCheck(property, schema, message) {
1155
- return custom$1({
1156
- parse: (value) => {
1157
- if (typeof value !== 'object' || value === null || !(property in value)) {
1158
- throw new Error(messageFromRefinementParam(message) || `Expected object with property "${property}"`);
1159
- }
1160
- const result = schema.safeParse(value[property]);
1161
- if (!result.success) {
1162
- throw new Error(messageFromRefinementParam(message) || result.error.message);
1163
- }
1164
- return value;
1165
- }
1166
- });
1167
- }
1168
- function getParsedType(value) {
1169
- if (value === null)
1170
- return 'null';
1171
- if (Array.isArray(value))
1172
- return 'array';
1173
- if (Number.isNaN(value))
1174
- return 'nan';
1175
- return typeof value;
1176
- }
1177
- const TimePrecision = {
1178
- Any: null,
1179
- Minute: -1,
1180
- Second: 0,
1181
- Millisecond: 3,
1182
- Microsecond: 6
1183
- };
1184
- const ZodFirstPartyTypeKind = {};
1185
- const $brand = Symbol.for('vld_brand');
1186
- const $input = Symbol.for('VldInput');
1187
- const $output = Symbol.for('VldOutput');
1188
- const ZodIssueCode = {
1189
- invalid_type: 'invalid_type',
1190
- too_big: 'too_big',
1191
- too_small: 'too_small',
1192
- invalid_format: 'invalid_format',
1193
- not_multiple_of: 'not_multiple_of',
1194
- unrecognized_keys: 'unrecognized_keys',
1195
- invalid_union: 'invalid_union',
1196
- invalid_key: 'invalid_key',
1197
- invalid_element: 'invalid_element',
1198
- invalid_value: 'invalid_value',
1199
- custom: 'custom'
1200
- };
1201
- const util = {
1202
- getParsedType,
1203
- propertyKeyTypes: new Set(['string', 'number', 'symbol']),
1204
- primitiveTypes: new Set(['string', 'number', 'bigint', 'boolean', 'symbol', 'undefined', 'null']),
1205
- assert: (condition, message = 'Assertion failed') => {
1206
- if (!condition) {
1207
- throw new Error(message);
1208
- }
1209
- },
1210
- assertNever: (value) => {
1211
- throw new Error(`Unexpected value: ${String(value)}`);
1212
- },
1213
- joinValues: (values, separator = ' | ') => values.map(value => JSON.stringify(value)).join(separator),
1214
- jsonStringifyReplacer: (_key, value) => typeof value === 'bigint' ? value.toString() : value,
1215
- nullish: (value) => value === null || value === undefined,
1216
- cached: (getter) => {
1217
- let initialized = false;
1218
- let value;
1219
- return () => {
1220
- if (!initialized) {
1221
- value = getter();
1222
- initialized = true;
1223
- }
1224
- return value;
1225
- };
1226
- }
1227
- };
1228
- const core = {
1229
- util,
1230
- regexes: REGEXES,
1231
- locales: localeNamespace,
1232
- NEVER: VldNever.create(),
1233
- TimePrecision,
1234
- ZodIssueCode,
1235
- globalRegistry,
1236
- config: configure,
1237
- getErrorMap: getGlobalErrorMap,
1238
- setErrorMap: setGlobalErrorMap,
1239
- parse: (schema, value) => schema.parse(value),
1240
- safeParse: (schema, value) => schema.safeParse(value),
1241
- parseAsync: (schema, value) => schema.parseAsync(value),
1242
- safeParseAsync: (schema, value) => schema.safeParseAsync(value)
1243
- };
1244
- /**
1245
- * Main API object with factory methods for all validators
1246
- */
1247
- const v = {
1248
- // Primitive validators
1249
- string: () => VldString.create(),
1250
- number: () => VldNumber.create(),
1251
- int: () => VldNumber.create().int(),
1252
- int32: () => VldNumber.create().int().min(-2147483648).max(2147483647),
1253
- uint32: () => VldNumber.create().uint32(),
1254
- uint64: () => VldNumber.create().uint64(),
1255
- int64: () => VldNumber.create().int64(),
1256
- float32: () => VldNumber.create().float32(),
1257
- float64: () => VldNumber.create().float64(),
1258
- boolean: () => VldBoolean.create(),
1259
- date: () => VldDate.create(),
1260
- bigint: () => VldBigInt.create(),
1261
- symbol: () => VldSymbol.create(),
1262
- stringbool: (options) => VldStringBool.create(options),
1263
- // Complex validators
1264
- array: (item) => VldArray.create(item),
1265
- object: (shape) => VldObject.create(shape),
1266
- strictObject: (shape) => VldObject.create(shape).strict(),
1267
- looseObject: (shape) => VldObject.create(shape).passthrough(),
1268
- tuple: (...items) => VldTuple.create(...items),
1269
- record: (value) => VldRecord.create(value),
1270
- partialRecord: (value) => VldRecord.create(value).partial(),
1271
- looseRecord: (value) => VldRecord.create(value).loose(),
1272
- set: (item) => VldSet.create(item),
1273
- map: (key, value) => VldMap.create(key, value),
1274
- // Union and intersection
1275
- union: (...validators) => VldUnion.create(...validators),
1276
- intersection: (first, second) => VldIntersection.create(first, second),
1277
- discriminatedUnion: (discriminator, ...options) => VldDiscriminatedUnion.create(discriminator, [...options]),
1278
- xor: (...options) => VldXor.create([...options]),
1279
- keyof: (schema) => schema.keyof(),
1280
- // Literal and enum
1281
- literal: (value) => VldLiteral.create(value),
1282
- enum: (...values) => VldEnum.create(values),
1283
- nativeEnum: (enumObject) => VldEnum.create(enumValuesFromNativeEnum(enumObject)),
1284
- // Special validators
1285
- any: () => VldAny.create(),
1286
- unknown: () => VldUnknown.create(),
1287
- void: () => VldVoid.create(),
1288
- never: () => VldNever.create(),
1289
- null: () => VldNull.create(),
1290
- undefined: () => VldUndefined.create(),
1291
- nan: () => VldNan.create(),
1292
- // NEVER constant - Zod 4 API parity for use in transforms
1293
- NEVER: VldNever.create(),
1294
- TimePrecision,
1295
- ZodIssueCode,
1296
- ZodFirstPartyTypeKind,
1297
- // Utility validators
1298
- optional: (validator) => VldOptional.create(validator),
1299
- nullable: (validator) => VldNullable.create(validator),
1300
- nullish: (validator) => VldNullish.create(validator),
1301
- exactOptional: (validator) => VldExactOptional.create(validator),
1302
- nonoptional: (validator, message) => validator.refine((value) => value !== undefined, messageFromRefinementParam(message)),
1303
- catch: (validator, fallbackValue) => validator.catch(fallbackValue),
1304
- prefault: (validator, defaultValue) => validator.default(typeof defaultValue === 'function' ? defaultValue() : defaultValue).prefault(),
1305
- readonly: (validator) => validator.readonly(),
1306
- pipe: (first, second) => first.pipe(second),
1307
- clone: (schema) => cloneSchema(schema),
1308
- describe: (schemaOrDescription, description) => schemaOrDescription instanceof VldBase
1309
- ? schemaOrDescription.describe(description || '')
1310
- : VldUnknown.create().describe(schemaOrDescription),
1311
- meta: (schemaOrMetadata, metadata) => schemaOrMetadata instanceof VldBase
1312
- ? schemaOrMetadata.meta(metadata || {})
1313
- : VldUnknown.create().meta(schemaOrMetadata),
1314
- transform: (schemaOrTransformer, transformer) => schemaOrTransformer instanceof VldBase
1315
- ? schemaOrTransformer.transform(transformer || ((value) => value))
1316
- : createTransform(schemaOrTransformer),
1317
- overwrite: (transformer) => createTransform(transformer),
1318
- refine: (schemaOrPredicate, predicateOrMessage, message) => schemaOrPredicate instanceof VldBase
1319
- ? schemaOrPredicate.refine(predicateOrMessage, messageFromRefinementParam(message))
1320
- : createRefinement(schemaOrPredicate, predicateOrMessage),
1321
- check: (schemaOrPredicate, predicateOrMessage, message) => schemaOrPredicate instanceof VldBase
1322
- ? schemaOrPredicate.check(predicateOrMessage, messageFromRefinementParam(message))
1323
- : createRefinement(schemaOrPredicate, predicateOrMessage),
1324
- superRefine: (schemaOrRefinement, refinement) => schemaOrRefinement instanceof VldBase
1325
- ? schemaOrRefinement.superRefine(refinement || (() => undefined))
1326
- : createSuperRefinement(schemaOrRefinement),
1327
- property: propertyCheck,
1328
- instanceof: (constructor, message) => custom$1({
1329
- parse: (value) => {
1330
- if (!(value instanceof constructor)) {
1331
- throw new Error(messageFromRefinementParam(message) || `Expected instance of ${constructor.name || 'provided constructor'}`);
1332
- }
1333
- return value;
1334
- }
1335
- }),
1336
- config: configure,
1337
- setErrorMap: setGlobalErrorMap,
1338
- getErrorMap: getGlobalErrorMap,
1339
- core,
1340
- util,
1341
- locales: localeNamespace,
1342
- // Recursive schemas
1343
- lazy: (schemaGetter) => VldLazy.create(schemaGetter),
1344
- // JSON validator
1345
- json: (schema) => VldJson.create(schema),
1346
- // Custom validator for type-safe user-defined schemas
1347
- custom: (options) => custom$1(options),
1348
- // File validator for file uploads
1349
- file: () => file$1(),
1350
- // Function validator for function validation
1351
- function: () => functionValidator(),
1352
- // Preprocessing
1353
- preprocess: (preprocessor, schema) => VldPreprocess.create(preprocessor, schema),
1354
- // Coercion API
1355
- coerce: {
1356
- string: () => VldCoerceString.create(),
1357
- number: () => VldCoerceNumber.create(),
1358
- boolean: () => VldCoerceBoolean.create(),
1359
- date: () => VldCoerceDate.create(),
1360
- bigint: () => VldCoerceBigInt.create(),
1361
- },
1362
- // String format validators (Zod 4 parity)
1363
- email: (options) => email$1(options),
1364
- url: () => VldString.create().url(),
1365
- uuid: (options) => uuid$1(options),
1366
- uuidv4: () => uuidv4$1(),
1367
- uuidv6: () => uuidv6$1(),
1368
- uuidv7: () => uuidv7$1(),
1369
- hostname: () => hostname$1(),
1370
- emoji: () => emoji$1(),
1371
- base64: () => base64$1(),
1372
- base64url: () => base64url$1(),
1373
- hex: () => hex$1(),
1374
- jwt: () => jwt$1(),
1375
- nanoid: () => nanoid$1(),
1376
- cuid: () => cuid$1(),
1377
- cuid2: () => cuid2$1(),
1378
- ulid: () => ulid$1(),
1379
- ipv4: () => ipv4$1(),
1380
- ipv6: () => ipv6$1(),
1381
- mac: () => mac$1(),
1382
- cidrv4: () => cidrv4$1(),
1383
- cidrv6: () => cidrv6$1(),
1384
- e164: () => e164$1(),
1385
- hash: (algorithm) => hash$1(algorithm),
1386
- iso: {
1387
- date: () => iso$1.date(),
1388
- time: () => iso$1.time(),
1389
- dateTime: () => iso$1.dateTime(),
1390
- duration: () => iso$1.duration(),
1391
- },
1392
- stringFormat: (name, validator) => stringFormat$1(name, validator),
1393
- minLength: (value, message) => VldString.create().min(value, message),
1394
- maxLength: (value, message) => VldString.create().max(value, message),
1395
- length: (value, message) => VldString.create().length(value, message),
1396
- regex: (pattern, message) => VldString.create().regex(pattern, message),
1397
- startsWith: (value, message) => VldString.create().startsWith(value, message),
1398
- endsWith: (value, message) => VldString.create().endsWith(value, message),
1399
- includes: (value, message) => VldString.create().includes(value, message),
1400
- trim: () => VldString.create().trim(),
1401
- toLowerCase: () => VldString.create().toLowerCase(),
1402
- lowercase: () => VldString.create().toLowerCase(),
1403
- toUpperCase: () => VldString.create().toUpperCase(),
1404
- uppercase: () => VldString.create().toUpperCase(),
1405
- gt: (value, message) => VldNumber.create().gt(value, message),
1406
- gte: (value, message) => VldNumber.create().gte(value, message),
1407
- lt: (value, message) => VldNumber.create().lt(value, message),
1408
- lte: (value, message) => VldNumber.create().lte(value, message),
1409
- positive: (message) => VldNumber.create().positive(message),
1410
- negative: (message) => VldNumber.create().negative(message),
1411
- nonnegative: (message) => VldNumber.create().nonnegative(message),
1412
- nonpositive: (message) => VldNumber.create().nonpositive(message),
1413
- multipleOf: (value, message) => VldNumber.create().multipleOf(value, message),
1414
- minSize: (value, message) => VldString.create().min(value, message),
1415
- maxSize: (value, message) => VldString.create().max(value, message),
1416
- size: (value, message) => VldString.create().length(value, message),
1417
- normalize: (form) => VldString.create().transform(value => value.normalize(form)),
1418
- slugify: () => VldString.create().transform(value => value
1419
- .normalize('NFKD')
1420
- .replace(/[\u0300-\u036f]/g, '')
1421
- .toLowerCase()
1422
- .trim()
1423
- .replace(/[^a-z0-9]+/g, '-')
1424
- .replace(/^-+|-+$/g, '')),
1425
- mime: (types, message) => VldFile.create().mime(types, message),
1426
- // Zod v4 parity string formats
1427
- xid: () => xid$1(),
1428
- guid: () => guid$1(),
1429
- httpUrl: () => httpUrl$1(),
1430
- ksuid: () => ksuid$1(),
1431
- regexes: REGEXES,
1432
- // Template literal validator
1433
- templateLiteral: (...components) => templateLiteral$1(...components),
1434
- // Codec validators (binary data validators)
1435
- base64Bytes: () => VldBase64.create(),
1436
- hexBytes: () => VldHex.create(),
1437
- uint8Array: () => VldUint8Array.create(),
1438
- // Codec factory
1439
- codec: (inputValidator, outputValidator, transform) => VldCodec.create(inputValidator, outputValidator, transform),
1440
- invertCodec: (codec) => codec.invert(),
1441
- // Promise validator (Zod v4 parity)
1442
- promise: (inner) => promise$1(inner),
1443
- // Root parse helpers (Zod v4 parity)
1444
- parse: (schema, value) => schema.parse(value),
1445
- safeParse: (schema, value) => schema.safeParse(value),
1446
- parseAsync: (schema, value) => schema.parseAsync(value),
1447
- safeParseAsync: (schema, value) => schema.safeParseAsync(value),
1448
- decode: (schema, value) => schema.parse(value),
1449
- safeDecode: (schema, value) => schema.safeParse(value),
1450
- decodeAsync: (schema, value) => schema.parseAsync(value),
1451
- safeDecodeAsync: (schema, value) => schema.safeParseAsync(value),
1452
- encode: (schema, value) => isCodec(schema)
1453
- ? schema.encode(value)
1454
- : schema.parse(value),
1455
- safeEncode: (schema, value) => isCodec(schema)
1456
- ? schema.safeEncode(value)
1457
- : schema.safeParse(value),
1458
- encodeAsync: async (schema, value) => isCodec(schema)
1459
- ? schema.encodeAsync(value)
1460
- : schema.parseAsync(value),
1461
- safeEncodeAsync: async (schema, value) => isCodec(schema)
1462
- ? schema.safeEncodeAsync(value)
1463
- : schema.safeParseAsync(value),
1464
- formatError: (error) => {
1465
- const formatted = { _errors: [] };
1466
- if (error instanceof VldError) {
1467
- for (const issue of error.issues) {
1468
- addFormattedIssue(formatted, issue.path, issue.message);
1469
- }
1470
- return formatted;
1471
- }
1472
- formatted._errors.push(toErrorMessage(error));
1473
- return formatted;
1474
- },
1475
- treeifyError: treeifyError,
1476
- prettifyError: prettifyError,
1477
- flattenError: flattenError,
1478
- toJSONSchema: toJSONSchema
1479
- };
1480
- /**
1481
- * Zod-compatible namespace alias.
1482
- */
1483
- const z = v;
1484
- /**
1485
- * Zod-compatible root-level factory aliases.
1486
- *
1487
- * VLD's primary API remains `v.*`, but Zod exposes most factories directly
1488
- * from the package root. Re-exporting these aliases makes migration less
1489
- * intrusive without changing existing behavior.
1490
- */
1491
- const { string, number, int, int32, uint32, uint64, int64, float32, float64, boolean, date, bigint, symbol, stringbool, array, object, strictObject, looseObject, tuple, record, partialRecord, looseRecord, set, union, intersection, discriminatedUnion, xor, keyof, literal, nativeEnum, any, unknown, nan, optional, nullable, nullish, exactOptional, nonoptional, readonly, pipe, clone, describe, meta, transform, overwrite, refine, check, superRefine, property, config, setErrorMap, getErrorMap, locales, lazy, json, custom, file, preprocess, coerce, email, url, uuid, uuidv4, uuidv6, uuidv7, hostname, emoji, base64, base64url, hex, jwt, nanoid, cuid, cuid2, ulid, ipv4, ipv6, mac, cidrv4, cidrv6, e164, hash, iso, stringFormat, normalize, slugify, mime, xid, guid, httpUrl, ksuid, regexes, templateLiteral, base64Bytes, hexBytes, uint8Array, codec, promise, prefault, parse, safeParse, parseAsync, safeParseAsync, decode, safeDecode, decodeAsync, safeDecodeAsync, encode, safeEncode, encodeAsync, safeEncodeAsync, formatError, NEVER } = v;
1492
- const catchFactory = v.catch;
1493
- const enumFactory = v.enum;
1494
- const functionFactory = v.function;
1495
- const instanceOfFactory = v.instanceof;
1496
- const mapFactory = v.map;
1497
- const neverFactory = v.never;
1498
- const nullFactory = v.null;
1499
- const undefinedFactory = v.undefined;
1500
- const voidFactory = v.void;
1501
- const defaultFactory = v;
1502
- const zodStringFactory = VldString;
1503
- function map(first, second) {
1504
- if (first instanceof VldBase && second instanceof VldBase) {
1505
- return v.map(first, second);
1506
- }
1507
- return map$1(first, second);
1508
- }
1509
- const minLength = (value, message) => v.string().min(value, message);
1510
- const maxLength = (value, message) => v.string().max(value, message);
1511
- const length = (value, message) => v.string().length(value, message);
1512
- const regex = (pattern, message) => v.string().regex(pattern, message);
1513
- const startsWith = (value, message) => v.string().startsWith(value, message);
1514
- const endsWith = (value, message) => v.string().endsWith(value, message);
1515
- const includes = (value, message) => v.string().includes(value, message);
1516
- const trim = () => v.string().trim();
1517
- const toLowerCase = () => v.string().toLowerCase();
1518
- const lowercase = toLowerCase;
1519
- const toUpperCase = () => v.string().toUpperCase();
1520
- const uppercase = toUpperCase;
1521
- const gt = (value, message) => v.number().gt(value, message);
1522
- const gte = (value, message) => v.number().gte(value, message);
1523
- const lt = (value, message) => v.number().lt(value, message);
1524
- const lte = (value, message) => v.number().lte(value, message);
1525
- const positive = (message) => v.number().positive(message);
1526
- const negative = (message) => v.number().negative(message);
1527
- const nonnegative = (message) => v.number().nonnegative(message);
1528
- const nonpositive = (message) => v.number().nonpositive(message);
1529
- const multipleOf = (value, message) => v.number().multipleOf(value, message);
1530
- const minSize = minLength;
1531
- const maxSize = maxLength;
1532
- const size = length;
1533
-
1534
- export { $brand, $input, $output, NEVER, TimePrecision, VldBase, VldError, VldIntersection, VldAny as ZodAny, VldArray as ZodArray, VldBigInt as ZodBigInt, VldBigInt as ZodBigIntFormat, VldBoolean as ZodBoolean, VldCodec as ZodCodec, VldDate as ZodDate, VldDiscriminatedUnion as ZodDiscriminatedUnion, VldEnum as ZodEnum, VldError as ZodError, VldExactOptional as ZodExactOptional, VldFile as ZodFile, ZodFirstPartyTypeKind, VldIntersection as ZodIntersection, ZodIssueCode, VldJson as ZodJSON, VldLazy as ZodLazy, VldLiteral as ZodLiteral, VldMap as ZodMap, VldNan as ZodNaN, VldNever as ZodNever, VldNull as ZodNull, VldNullable as ZodNullable, VldNumber as ZodNumber, VldNumber as ZodNumberFormat, VldObject as ZodObject, VldOptional as ZodOptional, VldPreprocess as ZodPreprocess, VldError as ZodRealError, VldRecord as ZodRecord, VldSet as ZodSet, VldString as ZodString, VldSymbol as ZodSymbol, VldTuple as ZodTuple, VldBase as ZodType, VldUndefined as ZodUndefined, VldUnion as ZodUnion, VldUnknown as ZodUnknown, VldVoid as ZodVoid, VldXor as ZodXor, zodStringFactory as _ZodString, defaultFactory as _default, functionFactory as _function, any, array, base64, base64Bytes, base64url, bigint, boolean, catchFactory as catch, check, cidrv4, cidrv6, clone, codec, coerce, config, core, createLogger, createNoOpLogger, cuid, cuid2, custom, date, decode, decodeAsync, v as default, describe, disableLogging, discriminatedUnion, e164, email, emoji, enableDebug, encode, encodeAsync, endsWith, enumFactory as enum, exactOptional, file, flattenError, float32, float64, formatError, fromJSONSchema, functionFactory as function, getErrorMap, getLogger, globalRegistry, gt, gte, guid, hash, hex, hexBytes, hostname, httpUrl, includes, initLogger, instanceOfFactory as instanceof, int, int32, int64, intersection, ipv4, ipv6, iso, json, jwt, keyof, ksuid, lazy, length, literal, locales, looseObject, looseRecord, lowercase, lt, lte, mac, map, mapFactory as mapSchema, maxLength, maxSize, meta, mime, minLength, minSize, multipleOf, nan, nanoid, nativeEnum, negative, neverFactory as never, nonnegative, nonoptional, nonpositive, normalize, nullFactory as null, nullable, nullish, number, object, optional, overwrite, parse, parseAsync, partialRecord, pipe, positive, prefault, preprocess, prettifyError, promise, property, readonly, record, refine, regex, regexes, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, setErrorMap, setLogLevel, size, slugify, startsWith, strictObject, string, stringFormat, stringbool, superRefine, symbol, templateLiteral, toJSONSchema, toLowerCase, toUpperCase, transform, treeifyError, trim, tuple, uint32, uint64, uint8Array, ulid, undefinedFactory as undefined, union, unknown, uppercase, url, util, uuid, uuidv4, uuidv6, uuidv7, v, voidFactory as void, xid, xor, z };
1
+ import{VLD_VALIDATOR_TYPES as V,configureSchemaCompositionFactories as S,VldPreprocess as O,VldBase as Z,VldExactOptional as E,VldNullish as M,VldNullable as L,VldOptional as I,resolveErrorMessage as _,VldPipe as T,VldDefault as N,VldPrefault as P,VldCatch as R,VldReadonly as U,VldMeta as D,VldRefine as $,VldTransform as F}from"./validators/base.js";export{VldBrand as ZodBranded}from"./validators/base.js";import{globalRegistry as J}from"./registry.js";export{registry}from"./registry.js";import{VldString as W}from"./validators/string.js";import{VldNumber as K}from"./validators/number.js";import{VldBoolean as G}from"./validators/boolean.js";import{VldDate as H}from"./validators/date.js";import{VldStringBool as X}from"./validators/string-bool.js";import{VldArray as Y}from"./validators/array.js";import{VldObject as Q}from"./validators/object.js";import{VldUnion as ee}from"./validators/union.js";import{VldLiteral as te}from"./validators/literal.js";import{VldBigInt as re}from"./validators/bigint.js";import{VldSymbol as ne}from"./validators/symbol.js";import{VldTuple as ae}from"./validators/tuple.js";import{VldRecord as oe}from"./validators/record.js";import{VldSet as ie}from"./validators/set.js";import{VldMap as se}from"./validators/map.js";import{VldEnum as ce}from"./validators/enum.js";import{VldIntersection as ue}from"./validators/intersection.js";import{VldAny as le}from"./validators/any.js";import{VldUnknown as me}from"./validators/unknown.js";import{VldVoid as de}from"./validators/void.js";import{VldNever as fe}from"./validators/never.js";import{VldNull as pe}from"./validators/null.js";import{VldUndefined as ye}from"./validators/undefined.js";import{VldNan as ve}from"./validators/nan.js";import{VldLazy as ge}from"./validators/lazy.js";import{VldDiscriminatedUnion as he}from"./validators/discriminated-union.js";import{VldXor as be}from"./validators/xor.js";import{VldJson as xe}from"./validators/json.js";import{templateLiteral as je}from"./validators/template-literal.js";export{VldTemplateLiteral as ZodTemplateLiteral}from"./validators/template-literal.js";import{custom as Ve}from"./validators/custom.js";export{VldCustom as ZodCustom,VldCustom as ZodSuccess}from"./validators/custom.js";import{VldFile as we,file as Se}from"./validators/file.js";import{functionValidator as Ae}from"./validators/function.js";export{VldFunction as ZodFunction}from"./validators/function.js";import{VldCodec as Oe}from"./validators/codec.js";import{VldBase64 as Ze}from"./validators/base64.js";import{VldHex as Ee}from"./validators/hex.js";import{VldUint8Array as Me}from"./validators/uint8array.js";import{promise as Le}from"./validators/promise.js";export{VldPromise as ZodPromise}from"./validators/promise.js";import{map as Ie}from"./compat/result.js";export{Err,Ok,ResultUtils,all,failure,flatMap,fromNullable,isErr,isOk,isResult,mapErr,match,success,tryCatch,tryCatchAsync,unwrap,unwrapOr}from"./compat/result.js";import{l as _e}from"./chunks/index-yjpbvFgw.js";export{s as setLocaleAsync}from"./chunks/index-yjpbvFgw.js";import{VldCoerceBigInt as Te,VldCoerceDate as Ne,VldCoerceBoolean as Pe,VldCoerceNumber as ke,VldCoerceString as Ce}from"./coercion/index.js";import{flattenError as Re,prettifyError as Ue,treeifyError as Be}from"./errors.js";export{prettifyErrorColored,prettifyErrorPlain}from"./errors.js";import{uuid as De,httpUrl as $e,email as ze,regexes as Fe,VldStringFormat as Je,ksuid as We,guid as qe,xid as Ke,stringFormat as Ge,iso as He,hash as Xe,e164 as Ye,creditCard as Qe,cidrv6 as et,cidrv4 as tt,mac as rt,ipv6 as nt,ipv4 as at,ulid as ot,cuid2 as it,cuid as st,nanoid as ct,jwt as ut,hex as lt,base64url as mt,base64 as dt,emoji as ft,hostname as pt,uuidv7 as yt,uuidv6 as vt,uuidv4 as gt,url as ht}from"./validators/string-formats.js";export{b as base64Json,a as base64ToBytes,c as base64ToUint8Array,d as base64UrlToBytes,e as base64urlToBytes,f as bytesToUtf8,g as epochMillisToDate,h as epochSecondsToDate,i as hexLowerToBytes,j as hexToBytes,k as hexToUint8Array,l as invertCodec,m as isoDatetimeToDate,n as jsonCodec,o as jwtPayload,p as numberToBigInt,s as stringToBigInt,q as stringToBoolean,r as stringToHttpURL,t as stringToInt,u as stringToNumber,v as stringToURL,w as stringToUint8Array,x as uint8ArrayToBase64,y as uint8ArrayToBase64Url,z as uint8ArrayToHex,A as uint8ArrayToString,B as uriComponent,C as utf8ToBytes}from"./chunks/index-CkbfQQ4n.js";export{createEmitter,createEventBus,withEmitter}from"./compat/emitter.js";export{createVldKernel,definePlugin,getVldKernel,resetVldKernel,usePlugin}from"./kernel.js";export{blue,bold,createTheme,cyan,dim,gray,green,grey,italic,magenta,default as pigment,red,strip,supportsColor,underline,vldTheme,white,yellow}from"./pigment.js";import{V as bt}from"./chunks/errors-core-Cqi4-9ew.js";export{getLocale,getMessages,getSupportedLocales,isLocaleLoaded,isLocaleSupported,registerLocale,setLocale}from"./locales/runtime.js";function xt(e,t={}){const r=function(e){const t=e.target;if("draft-4"===t)return{...e,target:"draft-04"};if("draft-7"===t)return{...e,target:"draft-07"};return e}(t),n=Vt(wt(e,r),r),a=r.target||"draft-2020-12";return"draft-04"===a?n.$schema??(n.$schema="http://json-schema.org/draft-04/schema#"):"draft-07"===a?n.$schema??(n.$schema="http://json-schema.org/draft-07/schema#"):"draft-2019-09"===a?n.$schema??(n.$schema="https://json-schema.org/draft/2019-09/schema"):"draft-2020-12"===a&&(n.$schema??(n.$schema="https://json-schema.org/draft/2020-12/schema")),n}function jt(e,t={}){if("boolean"==typeof e)return e?le.create():fe.create();let r;try{r=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}const n=Mt(r),a=n.meta();return t.registry&&a&&t.registry.add(n,a),n}function Vt(e,t){const r=t.target||"draft-2020-12",n={...e};if(Array.isArray(n.items)){const e=n.items.map(e=>Vt(e,t));"draft-2020-12"===r||"draft-2019-09"===r?(n.prefixItems=e,n.items=!1):n.items=e}else n.items&&"object"==typeof n.items&&(n.items=Vt(n.items,t));n.prefixItems&&(n.prefixItems=n.prefixItems.map(e=>Vt(e,t))),n.properties&&(n.properties=Object.fromEntries(Object.entries(n.properties).map(([e,r])=>[e,Vt(r,t)]))),n.additionalProperties&&"object"==typeof n.additionalProperties&&(n.additionalProperties=Vt(n.additionalProperties,t));for(const e of["anyOf","allOf","oneOf"])n[e]&&(n[e]=n[e].map(e=>Vt(e,t)));return n.not&&"object"==typeof n.not&&(n.not=Vt(n.not,t)),"openapi-3.0"===r&&function(e){if(Array.isArray(e.type)&&e.type.includes("null")){const t=e.type.filter(e=>"null"!==e);if(e.nullable=!0,1===t.length){const r=t[0];void 0!==r?e.type=r:delete e.type}else t.length>1?e.type=t:delete e.type}"number"==typeof e.exclusiveMinimum&&(e.minimum??(e.minimum=e.exclusiveMinimum),e.exclusiveMinimum=!0);"number"==typeof e.exclusiveMaximum&&(e.maximum??(e.maximum=e.exclusiveMaximum),e.exclusiveMaximum=!0)}(n),n}function wt(e,t){t.target;const r=e,n=e.validatorType;if("VldString"===e.constructor.name||n===V.STRING)return Ot(e,function(e,t){const r=t?.config?.jsonSchema||{},n={type:"string"};void 0!==r.exactLength?(n.minLength=r.exactLength,n.maxLength=r.exactLength):(void 0!==r.minLength&&(n.minLength=r.minLength),void 0!==r.maxLength&&(n.maxLength=r.maxLength));r.format&&(n.format=r.format);r.pattern&&(n.pattern=r.pattern);return n}(0,e),t);if("VldNumber"===e.constructor.name||n===V.NUMBER)return Ot(e,function(e){const t=e.config||{},r=t.jsonSchema||{},n=t.checks||[],a={type:r.type||"number"};void 0!==r.minimum&&(a.minimum=r.minimum);void 0!==r.maximum&&(a.maximum=r.maximum);void 0!==r.exclusiveMinimum&&(a.exclusiveMinimum=r.exclusiveMinimum);void 0!==r.exclusiveMaximum&&(a.exclusiveMaximum=r.exclusiveMaximum);void 0!==r.multipleOf&&(a.multipleOf=r.multipleOf);if(Object.keys(r).length>0)return a;for(const e of n){const t=e.toString();(t.includes(">=")||t.includes("min"))&&(a.minimum=0),(t.includes("<=")||t.includes("max"))&&(a.maximum=0),(t.includes("isInteger")||t.includes("int"))&&(a.type="integer"),t.includes("isSafeInteger")&&(a.type="integer"),t.includes("Number.isFinite")}return a}(e),t);if("VldBoolean"===e.constructor.name||n===V.BOOLEAN)return Ot(e,{type:"boolean"},t);if("VldBigInt"===e.constructor.name||n===V.BIGINT)return St(e,t,"BigInt",()=>function(e){const t=e.jsonSchema||e.config?.jsonSchema||{},r={type:"integer"};return Zt(r,"minimum","x-vld-minimum",t.minimum),Zt(r,"maximum","x-vld-maximum",t.maximum),Zt(r,"exclusiveMinimum","x-vld-exclusiveMinimum",t.exclusiveMinimum),Zt(r,"exclusiveMaximum","x-vld-exclusiveMaximum",t.exclusiveMaximum),r}(e));if("VldDate"===e.constructor.name||n===V.DATE)return St(e,t,"Date",()=>function(e){const t=e.jsonSchema||e.config?.jsonSchema||{},r={type:"string",format:"date-time"};t.formatMinimum&&(r.formatMinimum=t.formatMinimum);t.formatMaximum&&(r.formatMaximum=t.formatMaximum);t.formatExclusiveMinimum&&(r.formatExclusiveMinimum=t.formatExclusiveMinimum);t.formatExclusiveMaximum&&(r.formatExclusiveMaximum=t.formatExclusiveMaximum);return r}(e));if("VldArray"===e.constructor.name||n===V.ARRAY)return Ot(e,function(e,t){const r=e._item||e._inner||e.config?.itemValidator,n={type:"array"};r&&(n.items=wt(r,t));void 0!==e.config?.exactLength?(n.minItems=e.config.exactLength,n.maxItems=e.config.exactLength):(void 0!==e.config?.minLength&&(n.minItems=e.config.minLength),void 0!==e.config?.maxLength&&(n.maxItems=e.config.maxLength));e.config?.unique&&(n.uniqueItems=!0);return n}(e,t),t);if("VldObject"===e.constructor.name||n===V.OBJECT)return Ot(e,function(e,t){const r=e._shape||e.shape||e.config?.shape;if(!r)return{type:"object"};const n={},a=[];for(const[e,o]of Object.entries(r)){const r=o;n[e]=wt(r,t),Et(r)||a.push(e)}const o={type:"object",properties:n};a.length>0&&(o.required=a);e._passthrough||e._loose||e.config?.passthrough?o.additionalProperties=!0:e.config?.catchall?o.additionalProperties=wt(e.config.catchall,t):o.additionalProperties=!1;return o}(e,t),t);if("VldUnion"===e.constructor.name)return Ot(e,function(e,t){const r=e._validators||e._options||e.validators||[];return{anyOf:r.map(e=>wt(e,t))}}(e,t),t);if("VldLiteral"===e.constructor.name)return Ot(e,function(e){const t=e._literal??e.literal??e._value??e.value;return null===t?{type:"null"}:"string"==typeof t?{type:"string",const:t}:"number"==typeof t?{type:"number",const:t}:"boolean"==typeof t?{type:"boolean",const:t}:{const:t}}(e),t);if("VldEnum"===e.constructor.name)return Ot(e,function(e){const t=e._values||e.values;if(Array.isArray(t))return{enum:[...t]};return{}}(e),t);if("VldSet"===e.constructor.name||n===V.SET)return St(e,t,"Set",()=>function(e,t){const r=e.itemSchema||e.itemValidator||e._item||e._inner,n={type:"array",uniqueItems:!0,"x-vld-type":"set"};r&&(n.items=wt(r,t));return n}(e,t));if("VldMap"===e.constructor.name||n===V.MAP)return St(e,t,"Map",()=>function(e,t){const r=e.keySchema||e.keyValidator||e._key,n=e.valueSchema||e.valueValidator||e._value,a=r?wt(r,t):{},o=n?wt(n,t):{};return{type:"array","x-vld-type":"map",items:{type:"array",items:[a,o],minItems:2,maxItems:2}}}(e,t));if("VldRecord"===e.constructor.name||n===V.RECORD)return Ot(e,function(e,t){const r=e.valueSchema||e._value||e._inner||e.valueValidator;if(r)return{type:"object",additionalProperties:wt(r,t)};return{type:"object"}}(e,t),t);if("VldTuple"===e.constructor.name||n===V.TUPLE)return Ot(e,function(e,t){const r=e.items||e._items||e.validators;if(!r||!Array.isArray(r))return{type:"array"};return{type:"array",items:r.map(e=>wt(e,t)),minItems:r.length,maxItems:r.length}}(e,t),t);if("VldIntersection"===e.constructor.name)return Ot(e,function(e,t){const r=e._first||e.first,n=e._second||e.second,a=[];r&&a.push(wt(r,t));n&&a.push(wt(n,t));return 0===a.length?{}:1===a.length?a[0]??{}:{allOf:a}}(e,t),t);if("VldOptional"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);if(!r)return{};const n=wt(r,t);return n}(e,t),t);if("VldNullable"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);if(!r)return{type:"null"};const n=wt(r,t);if("string"==typeof n.type)return{type:[n.type,"null"]};if(Array.isArray(n.type))return n.type.push("null"),n;return{anyOf:[n,{type:"null"}]}}(e,t),t);if("VldNullish"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);if(!r)return{};const n=wt(r,t);if("string"==typeof n.type)return{...n,type:[n.type,"null"]};return n}(e,t),t);if("VldExactOptional"===e.constructor.name)return Ot(e,function(e,t){const r=At(e);return r?wt(r,t):{}}(e,t),t);if("VldLazy"===e.constructor.name)return Ot(e,{type:"object"},t);if("VldJson"===e.constructor.name)return Ot(e,{},t);if("VldAny"===e.constructor.name)return Ot(e,{},t);if("VldUnknown"===e.constructor.name)return Ot(e,{},t);if("VldNever"===e.constructor.name)return Ot(e,{not:{}},t);if("VldNull"===e.constructor.name)return Ot(e,{type:"null"},t);if("VldUndefined"===e.constructor.name)return St(e,t,"Undefined",()=>({not:{}}));if("VldNan"===e.constructor.name)return St(e,t,"NaN",()=>({type:"number",not:{}}));if("VldVoid"===e.constructor.name)return St(e,t,"Void",()=>({not:{}}));if("VldSymbol"===e.constructor.name)return St(e,t,"Symbol",()=>({}));if("VldBrand"===e.constructor.name)return Ot(e,wt(r.baseValidator,t),t);if("VldReadonly"===e.constructor.name)return Ot(e,wt(r.baseValidator,t),t);if("VldTransform"===e.constructor.name)return St(e,t,"Transform",()=>wt(At(r),t));if("VldMeta"===e.constructor.name){const n=wt(r.baseValidator,t);return Ot(e,n,t)}if("VldRefine"===e.constructor.name||"VldSuperRefine"===e.constructor.name)return Ot(e,wt(At(r),t),t);if("VldPipe"===e.constructor.name){const n="input"===t.io?r.first:r._next||r.second;return Ot(e,wt(n,t),t)}if("VldDefault"===e.constructor.name||"VldCatch"===e.constructor.name)return Ot(e,wt(At(r),t),t);if("VldPreprocess"===e.constructor.name)return St(e,t,"Preprocess",()=>wt(r._schema,t));if("VldCodec"===e.constructor.name){const n="input"===t.io?r.inputValidator:r.outputValidator;return Ot(e,wt(n,t),t)}if("VldCustom"===e.constructor.name)return St(e,t,"Custom",()=>({}));if("VldStringFormat"===e.constructor.name){return Ot(e,{type:"string",format:e._format},t)}return Ot(e,{},t)}function St(e,t,r,n){if("any"===t.unrepresentable)return Ot(e,{},t);if("vld"===t.unrepresentable)return Ot(e,n(),t);throw new Error(`${r} cannot be represented in JSON Schema`)}function At(e){return"function"==typeof e.unwrap?e.unwrap():e._inner||e._baseValidator||e.baseValidator||e.valueValidator}function Ot(e,t,r){if(!1===r.includeMetadata)return t;const n=function(e){const t=J.get(e),r=e,n="function"==typeof r.getMeta?r.getMeta():void 0;return t||n?{...n||{},...t||{}}:void 0}(e);if(!n)return t;const a={...t};return n.id&&(a.$id=n.id),n.title&&(a.title=n.title),n.description&&(a.description=n.description),n.examples&&!1!==r.includeExamples&&(a.examples=n.examples),void 0!==n.default&&(a.default=n.default),n.deprecated&&(a.deprecated=!0),n.readOnly&&(a.readOnly=!0),n.writeOnly&&(a.writeOnly=!0),a}function Zt(e,t,r,n){if(void 0===n)return;e[r]=n.toString();const a=function(e){const t=Number(e);if(Number.isSafeInteger(t))return BigInt(t)===e?t:void 0}(n);void 0!==a&&(e[t]=a)}function Et(e){const t=e.constructor.name;return"VldOptional"===t||"VldNullish"===t||"VldExactOptional"===t||e.validatorType===V.OPTIONAL||e.validatorType===V.NULLISH||e.validatorType===V.EXACT_OPTIONAL}function Mt(e){return function(e,t){const r={};t.$id&&(r.id=t.$id);t.title&&(r.title=t.title);t.description&&(r.description=t.description);t.examples&&(r.examples=t.examples);void 0!==t.default&&(r.default=t.default);t.deprecated&&(r.deprecated=!0);t.readOnly&&(r.readOnly=!0);t.writeOnly&&(r.writeOnly=!0);return Object.keys(r).length>0?e.meta(r):e}(function(e){if(e.$ref)return le.create();if(e.anyOf||e.oneOf){const t=(e.anyOf||e.oneOf).map(e=>Mt(e)).filter(Boolean);if(t.length>0)return ee.create(...t)}if(e.allOf){const t=e.allOf[0];if(void 0===t)return le.create();const r=Mt(t);if(e.allOf.length>1){const t=Mt({allOf:e.allOf.slice(1)});return ue.create(r,t)}return r}if(e.not)return le.create();if(void 0!==e.const)return te.create(e.const);if(e.enum)return ce.create(e.enum);const t=e.nullable&&"string"==typeof e.type?[e.type,"null"]:e.type;if("string"===t||void 0===t){let t=W.create();if(void 0!==e.minLength&&(t=t.min(e.minLength)),void 0!==e.maxLength&&(t=t.max(e.maxLength)),e.pattern&&(t=t.regex(new RegExp(e.pattern))),e.format)switch(e.format){case"date-time":case"date":case"time":break;case"email":return ze();case"uri":case"uri-reference":return $e();case"uuid":return De()}return t}if("number"===t||"integer"===t){let r=K.create();return"integer"===t&&(r=r.int()),void 0!==e.minimum&&(r=r.min(e.minimum)),void 0!==e.maximum&&(r=r.max(e.maximum)),"number"==typeof e.exclusiveMinimum&&(r=r.gt(e.exclusiveMinimum)),"number"==typeof e.exclusiveMaximum&&(r=r.lt(e.exclusiveMaximum)),!0===e.exclusiveMinimum&&void 0!==e.minimum&&(r=r.gt(e.minimum)),!0===e.exclusiveMaximum&&void 0!==e.maximum&&(r=r.lt(e.maximum)),void 0!==e.multipleOf&&(r=r.multipleOf(e.multipleOf)),r}if("boolean"===t)return G.create();if("array"===t){if(e.prefixItems&&e.prefixItems.length>0){const t=e.prefixItems.map(e=>Mt(e));return ae.create(...t)}if(Array.isArray(e.items)){const t=e.items.map(e=>Mt(e));return ae.create(...t)}return e.items&&!Array.isArray(e.items)?Y.create(Mt(e.items)):Y.create(le.create())}if("object"===t){if(e.properties){const t={},r=new Set(e.required||[]);for(const[n,a]of Object.entries(e.properties)){const e=Mt(a);t[n]=r.has(n)?e:e.optional()}let n=Q.create(t);if(!1===e.additionalProperties)n=n.strict();else if(!0===e.additionalProperties)n=n.passthrough();else if(e.additionalProperties){const t=Mt(e.additionalProperties);return oe.create(t)}return n}return Q.create({})}if("null"===t)return pe.create();if(Array.isArray(t)){const r=t.map(t=>Mt({...e,type:t,nullable:!1}));if(r.length>0)return ee.create(...r)}return le.create()}(e),e)}const Lt={debug:0,info:1,warn:2,error:3,silent:4},It="",_t="",Tt="",Nt={debug:"",info:"",warn:"",error:""},Pt={debug:"DEBUG",info:"INFO ",warn:"WARN ",error:"ERROR"};function kt(e={}){const t=e.name??"vld";let r=e.level??"warn";const n=e.handler??function(e){const t=e.colored??!0,r=e.timestamps??!0;return e=>{const n=[];if(r){const r=e.timestamp.toISOString().slice(11,23);n.push(t?`${_t}${r}${It}`:r)}const a=Pt[e.level],o=Nt[e.level];n.push(t?`${o}${a}${It}`:a),n.push(t?`${Tt}[${e.name}]${It}`:`[${e.name}]`),n.push(e.message);const i=n.join(" ");switch(e.level){case"debug":console.debug(i,void 0!==e.data?e.data:"");break;case"info":console.info(i,void 0!==e.data?e.data:"");break;case"warn":console.warn(i,void 0!==e.data?e.data:"");break;case"error":console.error(i,void 0!==e.data?e.data:"")}}}(e),a=(e,a,o)=>{if(Lt[e]<Lt[r])return;const i={level:e,message:a,data:o,timestamp:new Date,name:t};n(i)};return{debug:(e,t)=>a("debug",e,t),info:(e,t)=>a("info",e,t),warn:(e,t)=>a("warn",e,t),error:(e,t)=>a("error",e,t),isLevelEnabled:e=>Lt[e]>=Lt[r],setLevel:e=>{r=e},getLevel:()=>r,child:r=>kt({...e,name:`${t}:${r}`})}}let Ct=null;function Rt(e){return Ct=kt({name:"vld",...e}),Ct}function Ut(){return Ct}function Bt(e){Ct&&Ct.setLevel(e)}function Dt(){Ct?Ct.setLevel("debug"):Rt({level:"debug"})}function $t(){Ct&&Ct.setLevel("silent")}function zt(){return kt({level:"silent"})}const Ft=Symbol.for("@oxog/vld/global-state"),Jt=globalThis,Wt=Jt[Ft]??(Jt[Ft]={config:{}});function qt(e){return void 0===e||(Wt.config={...Wt.config,...e},"customError"in e?Wt.errorMap=e.customError:"errorMap"in e&&(Wt.errorMap=e.errorMap)),{...Wt.config}}function Kt(e){Wt.errorMap=e,Wt.config={...Wt.config,errorMap:e}}function Gt(){return Wt.errorMap}function Ht(e){const t=Object.keys(e).filter(e=>!/^\d+$/.test(e)).map(t=>e[t]).filter(e=>"string"==typeof e||"number"==typeof e),r=Array.from(new Set(t));if(0===r.length)throw new Error("nativeEnum requires at least one string or number value");return r}function Xt(e,t,r){let n=e;for(const e of t){const t=String(e),r=n[t];r&&!Array.isArray(r)||(n[t]={_errors:[]}),n=n[t]}n._errors.push(r)}function Yt(e){return void 0===e?void 0:_(e,"Refinement check failed")}function Qt(e){return Ve({parse:t=>{const r=e(t,{addIssue:()=>{},path:[]});if(null!==r&&"object"==typeof r&&"function"==typeof r.then)throw new Error("Use parseAsync for async transforms");return r},parseAsync:async t=>await Promise.resolve(e(t,{addIssue:()=>{},path:[]}))})}function er(e,t){return Ve({parse:r=>{const n=e(r);if(null!==n&&"object"==typeof n&&"function"==typeof n.then)throw new Error("Use parseAsync for async refinements");if(!n)throw new Error(Yt(t)||"Refinement check failed");return r},parseAsync:async r=>{if(!await e(r))throw new Error(Yt(t)||"Refinement check failed");return r}})}const tr={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6},rr={},nr=Symbol.for("vld_brand"),ar=Symbol.for("VldInput"),or=Symbol.for("VldOutput"),ir={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"},sr={getParsedType:function(e){return null===e?"null":Array.isArray(e)?"array":Number.isNaN(e)?"nan":typeof e},propertyKeyTypes:new Set(["string","number","symbol"]),primitiveTypes:new Set(["string","number","bigint","boolean","symbol","undefined","null"]),assert:(e,t="Assertion failed")=>{if(!e)throw new Error(t)},assertNever:e=>{throw new Error(`Unexpected value: ${String(e)}`)},joinValues:(e,t=" | ")=>e.map(e=>JSON.stringify(e)).join(t),jsonStringifyReplacer:(e,t)=>"bigint"==typeof t?t.toString():t,nullish:e=>null==e,cached:e=>{let t,r=!1;return()=>(r||(t=e(),r=!0),t)}},cr={util:sr,regexes:Fe,locales:_e,NEVER:fe.create(),TimePrecision:tr,ZodIssueCode:ir,globalRegistry:J,config:qt,getErrorMap:Gt,setErrorMap:Kt,parse:(e,t)=>e.parse(t),safeParse:(e,t)=>e.safeParse(t),parseAsync:(e,t)=>e.parseAsync(t),safeParseAsync:(e,t)=>e.safeParseAsync(t)};function ur(e){return Q.create(e||{})}function lr(e,t,r){const n=r.get(e);if(n)return n;if(e instanceof ge){const n=e,a=ge.create(()=>lr(n.unwrap(),t,r));return r.set(e,a),a}const a=function(e,t){const r=e;if(e instanceof Q){const n=e.shape,a={};let o=!1;for(const e of Object.keys(n))a[e]=t(n[e]),o||(o=a[e]!==n[e]);let i=r.config.catchall;if(i){const e=t(i);o||(o=e!==i),i=e}return o?new Q({...r.config,shape:a,catchall:i}):e}if(e instanceof Y){const n=t(r.element);return n===r.element?e:Y.create(n)}if(e instanceof ie){const n=t(r.itemSchema);return n===r.itemSchema?e:ie.create(n)}if(e instanceof se){const n=t(r.keySchema),a=t(r.valueSchema);return n===r.keySchema&&a===r.valueSchema?e:se.create(n,a)}if(e instanceof oe){const n=t(r.valueSchema),a=r.keySchema?t(r.keySchema):void 0,o=void 0!==r.keySchema&&a!==r.keySchema;return n!==r.valueSchema||o?oe.create(n,a):e}if(e instanceof ae){const n=e.items.map(t),a=n.some((e,t)=>e!==r.items[t]),o=null==r.restValidator?void 0:t(r.restValidator),i=null!=r.restValidator&&o!==r.restValidator;return a||i?new ae(n,r.errorMessage,o):e}if(e instanceof ee){const n=r.validators.map(t);return n.some((e,t)=>e!==r.validators[t])?new ee(n,r.errorMessage):e}if(e instanceof be){const n=r._options.map(t);return n.some((e,t)=>e!==r._options[t])?new be(n):e}if(e instanceof he){const n=r._options.map(t);return n.some((e,t)=>e!==r._options[t])?ee.create(...n):e}if(e instanceof ue){const n=t(r.validatorA),a=t(r.validatorB);return n===r.validatorA&&a===r.validatorB?e:ue.create(n,a)}if(e instanceof T){const n=t(r.first),a=t(r.second);return n===r.first&&a===r.second?e:new T(n,a)}if(e instanceof I){const n=t(r.baseValidator);return n===r.baseValidator?e:I.create(n)}if(e instanceof L){const n=t(r.baseValidator);return n===r.baseValidator?e:L.create(n)}if(e instanceof M){const n=t(r.baseValidator);return n===r.baseValidator?e:M.create(n)}if(e instanceof E){const n=t(r.baseValidator);return n===r.baseValidator?e:E.create(n)}if(e instanceof N){const n=t(r.baseValidator);return n===r.baseValidator?e:new N(n,r.defaultValue)}if(e instanceof P){const n=t(r.baseValidator);return n===r.baseValidator?e:new P(n,r.defaultValue)}if(e instanceof R){const n=t(r.baseValidator);return n===r.baseValidator?e:new R(n,r.fallbackValue)}if(e instanceof U){const n=t(r.baseValidator);return n===r.baseValidator?e:new U(n)}if(e instanceof D){const n=t(r.baseValidator);return n===r.baseValidator?e:new D(n,r.metadata)}if(e instanceof $){const n=t(r.baseValidator);return n===r.baseValidator?e:new $(n,r.predicate,r.customMessage)}if(e instanceof F){const n=t(r.baseValidator);return n===r.baseValidator?e:new F(n,r.transformer)}if(e instanceof O){const n=t(r._schema);return n===r._schema?e:new O(r._preprocessor,n)}return e}(e,e=>lr(e,t,r)),o=t(a)??a;return r.set(e,o),o}function mr(e){return lr(e,e=>e instanceof Q?e.partial():void 0,new Map)}function dr(e){return lr(e,e=>e instanceof T?e.first:void 0,new Map)}function fr(e){return lr(e,e=>e instanceof T?e.second:void 0,new Map)}S({array:e=>Y.create(e),union:(e,t)=>ee.create(e,t),intersection:(e,t)=>ue.create(e,t),toJSONSchema:(e,t)=>xt(e,t)});const pr={string:()=>W.create(),number:()=>K.create(),int:()=>K.create().int(),int32:()=>K.create().int().min(-2147483648).max(2147483647),uint32:()=>K.create().uint32(),uint64:()=>K.create().uint64(),int64:()=>K.create().int64(),float32:()=>K.create().float32(),float64:()=>K.create().float64(),boolean:()=>G.create(),date:()=>H.create(),bigint:()=>re.create(),symbol:()=>ne.create(),stringbool:e=>X.create(e),array:e=>Y.create(e),object:ur,strictObject:function(e){return ur(e).strict()},looseObject:function(e){return ur(e).passthrough()},tuple:function(...e){const t=Array.isArray(e[0])?e[0]:e.filter(e=>e instanceof Z),r=ae.create(...t);return Array.isArray(e[0])&&e[1]instanceof Z?r.rest(e[1]):r},record:function(e,t){return void 0===t?oe.create(e):oe.create(t,e)},partialRecord:function(e,t){return void 0===t?oe.create(e).partial():oe.create(t,e).partial()},looseRecord:function(e,t){return void 0===t?oe.create(e).loose():oe.create(t,e).loose()},set:e=>ie.create(e),map:(e,t)=>se.create(e,t),union:function(...e){const t=Array.isArray(e[0])?e[0]:e.filter(e=>e instanceof Z);return ee.create(...t)},intersection:(e,t)=>ue.create(e,t),discriminatedUnion:function(e,...t){const r=Array.isArray(t[0])?t[0]:t.filter(e=>e instanceof Z);return he.create(e,r)},xor:function(...e){const t=Array.isArray(e[0])?e[0]:e.filter(e=>e instanceof Z);return be.create(t)},keyof:e=>e.keyof(),deepPartial:mr,input:dr,output:fr,literal:function(e){return te.create(e)},enum:function(...e){const t=e[0],r=Array.isArray(t)?t:null!==t&&"object"==typeof t?Ht(t):e.filter(e=>"string"==typeof e||"number"==typeof e);return ce.create(r)},nativeEnum:e=>ce.create(Ht(e)),any:()=>le.create(),unknown:()=>me.create(),void:()=>de.create(),never:()=>fe.create(),null:()=>pe.create(),undefined:()=>ye.create(),nan:()=>ve.create(),NEVER:fe.create(),TimePrecision:tr,ZodIssueCode:ir,ZodFirstPartyTypeKind:rr,optional:e=>I.create(e),nullable:e=>L.create(e),nullish:e=>M.create(e),exactOptional:e=>E.create(e),nonoptional:(e,t)=>e.refine(e=>void 0!==e,Yt(t)),catch:(e,t)=>e.catch(t),prefault:(e,t)=>e.prefault(t),readonly:e=>e.readonly(),pipe:(e,t)=>e.pipe(t),clone:e=>e,describe:(e,t)=>e instanceof Z?e.describe(t||""):me.create().describe(e),meta:(e,t)=>e instanceof Z?e.meta(t||{}):me.create().meta(e),transform:(e,t)=>e instanceof Z?e.transform(t||(e=>e)):Qt(e),overwrite:e=>Qt(e),refine:(e,t,r)=>e instanceof Z?e.refine(t,Yt(r)):er(e,t),check:(e,t,r)=>e instanceof Z?e.check(t,Yt(r)):er(e,t),superRefine:(e,t)=>e instanceof Z?e.superRefine(t||(()=>{})):function(e){return me.create().superRefine(e)}(e),property:function(e,t,r){return Ve({parse:n=>{if("object"!=typeof n||null===n||!(e in n))throw new Error(Yt(r)||`Expected object with property "${e}"`);const a=t.safeParse(n[e]);if(!a.success)throw new Error(Yt(r)||a.error.message);return n}})},instanceof:(e,t)=>Ve({parse:r=>{if(!(r instanceof e))throw new Error(Yt(t)||`Expected instance of ${e.name||"provided constructor"}`);return r}}),config:qt,setErrorMap:Kt,getErrorMap:Gt,core:cr,util:sr,locales:_e,lazy:e=>ge.create(e),json:e=>xe.create(e),custom:e=>Ve(e),file:()=>Se(),function:()=>Ae(),preprocess:(e,t)=>O.create(e,t),coerce:{string:()=>Ce.create(),number:()=>ke.create(),boolean:()=>Pe.create(),date:()=>Ne.create(),bigint:()=>Te.create()},email:e=>ze(e),url:e=>ht(e),uuid:e=>De(e),uuidv4:()=>gt(),uuidv6:()=>vt(),uuidv7:()=>yt(),hostname:()=>pt(),emoji:()=>ft(),base64:()=>dt(),base64url:()=>mt(),hex:()=>lt(),jwt:()=>ut(),nanoid:()=>ct(),cuid:()=>st(),cuid2:()=>it(),ulid:()=>ot(),ipv4:()=>at(),ipv6:()=>nt(),mac:()=>rt(),cidrv4:()=>tt(),cidrv6:()=>et(),creditCard:e=>Qe(e),e164:()=>Ye(),hash:e=>Xe(e),iso:{ZodISODate:Je,ZodISODateTime:Je,ZodISODuration:Je,ZodISOTime:Je,date:()=>He.date(),time:e=>He.time(e),datetime:e=>He.datetime(e),dateTime:e=>He.dateTime(e),duration:()=>He.duration()},stringFormat:(e,t)=>Ge(e,t),minLength:(e,t)=>W.create().min(e,t),maxLength:(e,t)=>W.create().max(e,t),length:(e,t)=>W.create().length(e,t),regex:(e,t)=>W.create().regex(e,t),startsWith:(e,t)=>W.create().startsWith(e,t),endsWith:(e,t)=>W.create().endsWith(e,t),includes:(e,t)=>W.create().includes(e,t),trim:()=>W.create().trim(),toLowerCase:()=>W.create().toLowerCase(),lowercase:()=>W.create().toLowerCase(),toUpperCase:()=>W.create().toUpperCase(),uppercase:()=>W.create().toUpperCase(),gt:(e,t)=>K.create().gt(e,t),gte:(e,t)=>K.create().gte(e,t),lt:(e,t)=>K.create().lt(e,t),lte:(e,t)=>K.create().lte(e,t),positive:e=>K.create().positive(e),negative:e=>K.create().negative(e),nonnegative:e=>K.create().nonnegative(e),nonpositive:e=>K.create().nonpositive(e),multipleOf:(e,t)=>K.create().multipleOf(e,t),minSize:(e,t)=>W.create().min(e,t),maxSize:(e,t)=>W.create().max(e,t),size:(e,t)=>W.create().length(e,t),normalize:e=>W.create().transform(t=>t.normalize(e)),slugify:()=>W.create().transform(e=>e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")),mime:(e,t)=>we.create().mime(e,t),xid:()=>Ke(),guid:()=>qe(),httpUrl:()=>$e(),ksuid:()=>We(),regexes:Fe,templateLiteral:(...e)=>je(...e),base64Bytes:()=>Ze.create(),hexBytes:()=>Ee.create(),uint8Array:()=>Me.create(),codec:(e,t,r)=>Oe.create(e,t,r),invertCodec:e=>e.invert(),promise:e=>Le(e),parse:(e,t)=>e.parse(t),safeParse:(e,t)=>e.safeParse(t),parseAsync:(e,t)=>e.parseAsync(t),safeParseAsync:(e,t)=>e.safeParseAsync(t),decode:(e,t)=>e.parse(t),safeDecode:(e,t)=>e.safeParse(t),decodeAsync:(e,t)=>e.parseAsync(t),safeDecodeAsync:(e,t)=>e.safeParseAsync(t),encode:(e,t)=>e.encode(t),safeEncode:(e,t)=>e.safeEncode(t),encodeAsync:(e,t)=>e.encodeAsync(t),safeEncodeAsync:(e,t)=>e.safeEncodeAsync(t),formatError:e=>{const t={_errors:[]};if(e instanceof bt){for(const r of e.issues)Xt(t,r.path,r.message);return t}return t._errors.push(function(e){return e instanceof Error?e.message:String(e)}(e)),t},treeifyError:Be,prettifyError:Ue,flattenError:Re,toJSONSchema:xt,fromJSONSchema:jt},yr=pr,{string:vr,number:gr,int:hr,int32:br,uint32:xr,uint64:jr,int64:Vr,float32:wr,float64:Sr,boolean:Ar,date:Or,bigint:Zr,symbol:Er,stringbool:Mr,array:Lr,object:Ir,strictObject:_r,looseObject:Tr,tuple:Nr,record:Pr,partialRecord:kr,looseRecord:Cr,set:Rr,union:Ur,intersection:Br,discriminatedUnion:Dr,xor:$r,keyof:zr,literal:Fr,nativeEnum:Jr,any:Wr,unknown:qr,nan:Kr,optional:Gr,nullable:Hr,nullish:Xr,exactOptional:Yr,nonoptional:Qr,readonly:en,pipe:tn,clone:rn,describe:nn,meta:an,transform:on,overwrite:sn,refine:cn,check:un,superRefine:ln,property:mn,config:dn,setErrorMap:fn,getErrorMap:pn,locales:yn,lazy:vn,json:gn,custom:hn,file:bn,preprocess:xn,coerce:jn,email:Vn,url:wn,uuid:Sn,uuidv4:An,uuidv6:On,uuidv7:Zn,hostname:En,emoji:Mn,base64:Ln,base64url:In,hex:_n,jwt:Tn,nanoid:Nn,cuid:Pn,cuid2:kn,ulid:Cn,ipv4:Rn,ipv6:Un,mac:Bn,cidrv4:Dn,cidrv6:$n,creditCard:zn,e164:Fn,hash:Jn,iso:Wn,stringFormat:qn,normalize:Kn,slugify:Gn,mime:Hn,xid:Xn,guid:Yn,httpUrl:Qn,ksuid:ea,regexes:ta,templateLiteral:ra,base64Bytes:na,hexBytes:aa,uint8Array:oa,codec:ia,promise:sa,prefault:ca,parse:ua,safeParse:la,parseAsync:ma,safeParseAsync:da,decode:fa,safeDecode:pa,decodeAsync:ya,safeDecodeAsync:va,encode:ga,safeEncode:ha,encodeAsync:ba,safeEncodeAsync:xa,formatError:ja,NEVER:Va}=pr,wa=pr.catch,Sa=pr.enum,Aa=pr.function,Oa=pr.instanceof,Za=pr.map,Ea=pr.never,Ma=pr.null,La=pr.undefined,Ia=pr.void,_a=pr,Ta=W;function Na(e,t){return e instanceof Z&&t instanceof Z?pr.map(e,t):Ie(e,t)}const Pa=(e,t)=>pr.string().min(e,t),ka=(e,t)=>pr.string().max(e,t),Ca=(e,t)=>pr.string().length(e,t),Ra=(e,t)=>pr.string().regex(e,t),Ua=(e,t)=>pr.string().startsWith(e,t),Ba=(e,t)=>pr.string().endsWith(e,t),Da=(e,t)=>pr.string().includes(e,t),$a=()=>pr.string().trim(),za=()=>pr.string().toLowerCase(),Fa=za,Ja=()=>pr.string().toUpperCase(),Wa=Ja,qa=(e,t)=>pr.number().gt(e,t),Ka=(e,t)=>pr.number().gte(e,t),Ga=(e,t)=>pr.number().lt(e,t),Ha=(e,t)=>pr.number().lte(e,t),Xa=e=>pr.number().positive(e),Ya=e=>pr.number().negative(e),Qa=e=>pr.number().nonnegative(e),eo=e=>pr.number().nonpositive(e),to=(e,t)=>pr.number().multipleOf(e,t),ro=Pa,no=ka,ao=Ca;export{nr as $brand,ar as $input,or as $output,Va as NEVER,tr as TimePrecision,Z as VldBase,bt as VldError,ue as VldIntersection,D as VldMeta,le as ZodAny,Y as ZodArray,Je as ZodBase64,Je as ZodBase64URL,re as ZodBigInt,re as ZodBigIntFormat,G as ZodBoolean,Je as ZodCIDRv4,Je as ZodCIDRv6,Je as ZodCUID,Je as ZodCUID2,R as ZodCatch,Oe as ZodCodec,Je as ZodCreditCard,Je as ZodCustomStringFormat,H as ZodDate,N as ZodDefault,he as ZodDiscriminatedUnion,Je as ZodE164,Je as ZodEmail,Je as ZodEmoji,ce as ZodEnum,bt as ZodError,E as ZodExactOptional,we as ZodFile,rr as ZodFirstPartyTypeKind,Je as ZodGUID,Je as ZodIPv4,Je as ZodIPv6,Je as ZodISODate,Je as ZodISODateTime,Je as ZodISODuration,Je as ZodISOTime,ue as ZodIntersection,ir as ZodIssueCode,xe as ZodJSON,Je as ZodJWT,Je as ZodKSUID,ge as ZodLazy,te as ZodLiteral,Je as ZodMAC,se as ZodMap,D as ZodMeta,ve as ZodNaN,Je as ZodNanoID,fe as ZodNever,$ as ZodNonOptional,pe as ZodNull,L as ZodNullable,K as ZodNumber,K as ZodNumberFormat,Q as ZodObject,I as ZodOptional,T as ZodPipe,P as ZodPrefault,O as ZodPreprocess,U as ZodReadonly,bt as ZodRealError,oe as ZodRecord,ie as ZodSet,W as ZodString,Je as ZodStringFormat,ne as ZodSymbol,F as ZodTransform,ae as ZodTuple,Z as ZodType,Je as ZodULID,Je as ZodURL,Je as ZodUUID,ye as ZodUndefined,ee as ZodUnion,me as ZodUnknown,de as ZodVoid,Je as ZodXID,be as ZodXor,Ta as _ZodString,_a as _default,Aa as _function,Wr as any,Lr as array,Ln as base64,na as base64Bytes,In as base64url,Zr as bigint,Ar as boolean,wa as catch,un as check,Dn as cidrv4,$n as cidrv6,rn as clone,ia as codec,jn as coerce,dn as config,cr as core,kt as createLogger,zt as createNoOpLogger,zn as creditCard,Pn as cuid,kn as cuid2,hn as custom,Or as date,fa as decode,ya as decodeAsync,mr as deepPartial,pr as default,nn as describe,$t as disableLogging,Dr as discriminatedUnion,Fn as e164,Vn as email,Mn as emoji,Dt as enableDebug,ga as encode,ba as encodeAsync,Ba as endsWith,Sa as enum,Yr as exactOptional,bn as file,Re as flattenError,wr as float32,Sr as float64,ja as formatError,jt as fromJSONSchema,Aa as function,pn as getErrorMap,Ut as getLogger,J as globalRegistry,qa as gt,Ka as gte,Yn as guid,Jn as hash,_n as hex,aa as hexBytes,En as hostname,Qn as httpUrl,Da as includes,Rt as initLogger,dr as input,Oa as instanceof,hr as int,br as int32,Vr as int64,Br as intersection,Rn as ipv4,Un as ipv6,Wn as iso,gn as json,Tn as jwt,zr as keyof,ea as ksuid,vn as lazy,Ca as length,Fr as literal,yn as locales,Tr as looseObject,Cr as looseRecord,Fa as lowercase,Ga as lt,Ha as lte,Bn as mac,Na as map,Za as mapSchema,ka as maxLength,no as maxSize,an as meta,Hn as mime,Pa as minLength,ro as minSize,to as multipleOf,Kr as nan,Nn as nanoid,Jr as nativeEnum,Ya as negative,Ea as never,Qa as nonnegative,Qr as nonoptional,eo as nonpositive,Kn as normalize,Ma as null,Hr as nullable,Xr as nullish,gr as number,Ir as object,Gr as optional,fr as output,sn as overwrite,ua as parse,ma as parseAsync,kr as partialRecord,tn as pipe,Xa as positive,ca as prefault,xn as preprocess,Ue as prettifyError,sa as promise,mn as property,en as readonly,Pr as record,cn as refine,Ra as regex,ta as regexes,pa as safeDecode,va as safeDecodeAsync,ha as safeEncode,xa as safeEncodeAsync,la as safeParse,da as safeParseAsync,Rr as set,fn as setErrorMap,Bt as setLogLevel,ao as size,Gn as slugify,Ua as startsWith,_r as strictObject,vr as string,qn as stringFormat,Mr as stringbool,ln as superRefine,Er as symbol,ra as templateLiteral,xt as toJSONSchema,za as toLowerCase,Ja as toUpperCase,on as transform,Be as treeifyError,$a as trim,Nr as tuple,xr as uint32,jr as uint64,oa as uint8Array,Cn as ulid,La as undefined,Ur as union,qr as unknown,Wa as uppercase,wn as url,sr as util,Sn as uuid,An as uuidv4,On as uuidv6,Zn as uuidv7,pr as v,Ia as void,Xn as xid,$r as xor,yr as z};