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