@oxog/vld 2.0.2 → 2.0.3

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 (48) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +20 -20
  3. package/README.md +2 -2
  4. package/dist/chunks/{bigint-DgsCr2dC.js → bigint-CRS0QVsy.js} +147 -2
  5. package/dist/chunks/bigint-CRS0QVsy.js.map +1 -0
  6. package/dist/chunks/{date-ODue_rtq.js → date-50JV_Mfj.js} +2 -2
  7. package/dist/chunks/{date-ODue_rtq.js.map → date-50JV_Mfj.js.map} +1 -1
  8. package/dist/chunks/{index-CETyGkrv.js → index-DO8CFMxD.js} +4 -4
  9. package/dist/chunks/index-DO8CFMxD.js.map +1 -0
  10. package/dist/chunks/{json-o20GFhTh.js → json-Cp4WO0M9.js} +4 -4
  11. package/dist/chunks/json-Cp4WO0M9.js.map +1 -0
  12. package/dist/chunks/{unknown-SLIH1VCf.js → unknown-Dhzri_T-.js} +2 -2
  13. package/dist/chunks/unknown-Dhzri_T-.js.map +1 -0
  14. package/dist/cjs/index.cjs +777 -1
  15. package/dist/cjs/index.cjs.map +1 -1
  16. package/dist/cjs/locales/index.cjs.map +1 -1
  17. package/dist/cjs/mini.cjs +145 -0
  18. package/dist/cjs/mini.cjs.map +1 -1
  19. package/dist/cli/commands/validate.d.ts.map +1 -1
  20. package/dist/codecs/index.js +3 -3
  21. package/dist/coercion/index.js +2 -2
  22. package/dist/coercion/index.js.map +1 -1
  23. package/dist/index.d.ts +244 -0
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +550 -11
  26. package/dist/index.js.map +1 -1
  27. package/dist/mini.js +5 -5
  28. package/dist/utils/json-schema.d.ts +67 -0
  29. package/dist/utils/json-schema.d.ts.map +1 -0
  30. package/dist/validators/base.d.ts +79 -0
  31. package/dist/validators/base.d.ts.map +1 -1
  32. package/dist/validators/index.d.ts +3 -2
  33. package/dist/validators/index.d.ts.map +1 -1
  34. package/dist/validators/index.js +514 -4
  35. package/dist/validators/index.js.map +1 -1
  36. package/dist/validators/number.d.ts +30 -0
  37. package/dist/validators/number.d.ts.map +1 -1
  38. package/dist/validators/promise.d.ts +53 -0
  39. package/dist/validators/promise.d.ts.map +1 -0
  40. package/dist/validators/string-formats.d.ts +6 -0
  41. package/dist/validators/string-formats.d.ts.map +1 -1
  42. package/package.json +6 -5
  43. package/dist/chunks/bigint-DgsCr2dC.js.map +0 -1
  44. package/dist/chunks/index-BZqWZvVe.js +0 -426
  45. package/dist/chunks/index-BZqWZvVe.js.map +0 -1
  46. package/dist/chunks/index-CETyGkrv.js.map +0 -1
  47. package/dist/chunks/json-o20GFhTh.js.map +0 -1
  48. package/dist/chunks/unknown-SLIH1VCf.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { h as VldPreprocess, g as VldNullish, f as VldNullable, e as VldOptional, d as VldBigInt, c as VldDate, b as VldBoolean, a as VldNumber, V as VldString } from './chunks/bigint-DgsCr2dC.js';
2
- export { i as VldBase, r as getLocale, t as getMessages, s as setLocale } from './chunks/bigint-DgsCr2dC.js';
3
- import { u as VldJson, t as VldLazy, p as VldNever, s as VldNan, r as VldUndefined, q as VldNull, o as VldVoid, n as VldAny, m as VldEnum, l as VldLiteral, k as VldXor, j as VldDiscriminatedUnion, i as VldIntersection, h as VldUnion, g as VldMap, f as VldSet, e as VldRecord, d as VldTuple, c as VldObject, b as VldArray, a as VldStringBool, V as VldSymbol } from './chunks/json-o20GFhTh.js';
4
- import { V as VldUnknown } from './chunks/unknown-SLIH1VCf.js';
5
- import { t as templateLiteral, s as stringFormat, i as iso, h as hash, e as e164, c as cidrv6, a as cidrv4, m as mac, b as ipv6, d as ipv4, u as ulid, f as cuid2, g as cuid, n as nanoid, j as jwt, k as hex, l as base64url, o as base64, p as emoji, q as hostname, r as uuidv4, v as uuid, w as email, x as functionValidator, y as file, z as custom } from './chunks/index-BZqWZvVe.js';
6
- import { V as VldCodec, a as VldUint8Array, b as VldHex, c as VldBase64 } from './chunks/index-CETyGkrv.js';
7
- export { D as base64Json, w as base64ToBytes, d as base64ToUint8Array, x as base64UrlToBytes, y as base64urlToBytes, C as bytesToUtf8, p as epochMillisToDate, o as epochSecondsToDate, A as hexLowerToBytes, z as hexToBytes, h as hexToUint8Array, m as isoDatetimeToDate, q as jsonCodec, E as jwtPayload, n as numberToBigInt, k as stringToBigInt, l as stringToBoolean, t as stringToHttpURL, j as stringToInt, i as stringToNumber, r as stringToURL, s as stringToUint8Array, u as uint8ArrayToBase64, e as uint8ArrayToBase64Url, f as uint8ArrayToHex, g as uint8ArrayToString, v as uriComponent, B as utf8ToBytes } from './chunks/index-CETyGkrv.js';
8
- import { V as VldCoerceDate, a as VldCoerceBoolean, b as VldCoerceNumber, c as VldCoerceString } from './chunks/date-ODue_rtq.js';
1
+ import { g as VldPreprocess, r as VldExactOptional, e as VldNullish, d as VldNullable, f as VldOptional, V as VldBigInt, b as VldDate, a as VldBoolean, c as VldNumber, h as VldString } from './chunks/bigint-CRS0QVsy.js';
2
+ export { i as VldBase, s as VldMeta, t as getLocale, u as getMessages, v as setLocale } from './chunks/bigint-CRS0QVsy.js';
3
+ import { f as VldJson, g as VldLazy, V as VldNever, l as VldNan, r as VldUndefined, m as VldNull, t as VldVoid, a as VldAny, d as VldEnum, h as VldLiteral, u as VldXor, c as VldDiscriminatedUnion, e as VldIntersection, s as VldUnion, k as VldMap, n as VldSet, j as VldRecord, q as VldTuple, i as VldObject, b as VldArray, o as VldStringBool, p as VldSymbol } from './chunks/json-Cp4WO0M9.js';
4
+ import { V as VldUnknown } from './chunks/unknown-Dhzri_T-.js';
5
+ import { promise, templateLiteral, httpUrl, guid, xid, stringFormat, iso, hash, e164, cidrv6, cidrv4, mac, ipv6, ipv4, ulid, cuid2, cuid, nanoid, jwt, hex, base64url, base64, emoji, hostname, uuidv4, uuid, email, functionValidator, file, custom } from './validators/index.js';
6
+ import { V as VldCodec, a as VldUint8Array, b as VldHex, c as VldBase64 } from './chunks/index-DO8CFMxD.js';
7
+ export { d as base64Json, e as base64ToBytes, f as base64ToUint8Array, g as base64UrlToBytes, h as base64urlToBytes, i as bytesToUtf8, j as epochMillisToDate, k as epochSecondsToDate, l as hexLowerToBytes, m as hexToBytes, n as hexToUint8Array, o as isoDatetimeToDate, p as jsonCodec, q as jwtPayload, r as numberToBigInt, s as stringToBigInt, t as stringToBoolean, u as stringToHttpURL, v as stringToInt, w as stringToNumber, x as stringToURL, y as stringToUint8Array, z as uint8ArrayToBase64, A as uint8ArrayToBase64Url, B as uint8ArrayToHex, C as uint8ArrayToString, D as uriComponent, E as utf8ToBytes } from './chunks/index-DO8CFMxD.js';
8
+ import { V as VldCoerceDate, a as VldCoerceBoolean, b as VldCoerceNumber, c as VldCoerceString } from './chunks/date-50JV_Mfj.js';
9
9
  import { VldCoerceBigInt } from './coercion/index.js';
10
10
  export { VldError, flattenError, prettifyError, prettifyErrorColored, prettifyErrorPlain, treeifyError } from './errors.js';
11
11
  export { Err, Ok, ResultUtils, all, failure, flatMap, fromNullable, isErr, isOk, isResult, map, mapErr, match, success, tryCatch, tryCatchAsync, unwrap, unwrapOr } from './compat/result.js';
12
12
  export { createEmitter, createEventBus, withEmitter } from './compat/emitter.js';
13
13
  export { createVldKernel, definePlugin, getVldKernel, resetVldKernel, usePlugin } from './kernel.js';
14
- export { blue, bold, createTheme, cyan, dim, gray, green, grey, italic, magenta, pigment, red, strip, supportsColor, underline, vldTheme, white, yellow } from './pigment.js';
14
+ export { blue, bold, createTheme, cyan, dim, gray, green, grey, italic, magenta, default as pigment, red, strip, supportsColor, underline, vldTheme, white, yellow } from './pigment.js';
15
15
 
16
16
  /**
17
17
  * VLD Logger
@@ -191,6 +191,533 @@ function createNoOpLogger() {
191
191
  return createLogger({ level: 'silent' });
192
192
  }
193
193
 
194
+ /**
195
+ * JSON Schema support for VLD validators
196
+ * Provides conversion between VLD schemas and JSON Schema
197
+ */
198
+ /**
199
+ * Convert a VLD schema to JSON Schema
200
+ * @param schema The VLD schema to convert
201
+ * @param options Conversion options
202
+ * @returns JSON Schema definition
203
+ */
204
+ function toJSONSchema(schema, options = {}) {
205
+ return schemaToJSONSchema(schema, options);
206
+ }
207
+ /**
208
+ * Convert a JSON Schema to a VLD schema
209
+ * @param json The JSON Schema definition
210
+ * @returns A VLD schema
211
+ */
212
+ function fromJSONSchema(json) {
213
+ return jsonSchemaToVLD(json);
214
+ }
215
+ /**
216
+ * Internal function to convert VLD schema to JSON Schema
217
+ */
218
+ function schemaToJSONSchema(schema, options) {
219
+ // Handle primitives
220
+ if (schema.constructor.name === 'VldString') {
221
+ return buildStringSchema();
222
+ }
223
+ if (schema.constructor.name === 'VldNumber') {
224
+ return buildNumberSchema(schema);
225
+ }
226
+ if (schema.constructor.name === 'VldBoolean') {
227
+ return { type: 'boolean' };
228
+ }
229
+ if (schema.constructor.name === 'VldBigInt') {
230
+ return { type: 'integer' };
231
+ }
232
+ if (schema.constructor.name === 'VldDate') {
233
+ return { type: 'string', format: 'date-time' };
234
+ }
235
+ if (schema.constructor.name === 'VldArray') {
236
+ return buildArraySchema(schema, options);
237
+ }
238
+ if (schema.constructor.name === 'VldObject') {
239
+ return buildObjectSchema(schema, options);
240
+ }
241
+ // Handle union types
242
+ if (schema.constructor.name === 'VldUnion') {
243
+ return buildUnionSchema(schema, options);
244
+ }
245
+ // Handle literal types
246
+ if (schema.constructor.name === 'VldLiteral') {
247
+ return buildLiteralSchema(schema);
248
+ }
249
+ if (schema.constructor.name === 'VldEnum') {
250
+ return buildEnumSchema(schema);
251
+ }
252
+ if (schema.constructor.name === 'VldRecord') {
253
+ return buildRecordSchema(schema, options);
254
+ }
255
+ if (schema.constructor.name === 'VldTuple') {
256
+ return buildTupleSchema(schema, options);
257
+ }
258
+ if (schema.constructor.name === 'VldIntersection') {
259
+ return buildIntersectionSchema(schema, options);
260
+ }
261
+ if (schema.constructor.name === 'VldOptional') {
262
+ return buildOptionalSchema(schema, options);
263
+ }
264
+ if (schema.constructor.name === 'VldNullable') {
265
+ return buildNullableSchema(schema, options);
266
+ }
267
+ if (schema.constructor.name === 'VldNullish') {
268
+ return buildNullishSchema(schema, options);
269
+ }
270
+ if (schema.constructor.name === 'VldExactOptional') {
271
+ return buildExactOptionalSchema(schema, options);
272
+ }
273
+ if (schema.constructor.name === 'VldLazy') {
274
+ return { type: 'object' }; // Placeholder for recursive schemas
275
+ }
276
+ if (schema.constructor.name === 'VldJson') {
277
+ return {}; // Any JSON
278
+ }
279
+ if (schema.constructor.name === 'VldAny') {
280
+ return {}; // JSON Schema true
281
+ }
282
+ if (schema.constructor.name === 'VldUnknown') {
283
+ return {}; // JSON Schema true
284
+ }
285
+ if (schema.constructor.name === 'VldNever') {
286
+ return { not: {} }; // JSON Schema false
287
+ }
288
+ if (schema.constructor.name === 'VldNull') {
289
+ return { type: 'null' };
290
+ }
291
+ if (schema.constructor.name === 'VldUndefined') {
292
+ return { not: {} }; // Undefined can't be represented in JSON Schema
293
+ }
294
+ if (schema.constructor.name === 'VldNan') {
295
+ return { type: 'number', not: {} }; // NaN is a number type constraint
296
+ }
297
+ if (schema.constructor.name === 'VldVoid') {
298
+ return { not: {} }; // Void/undefined can't be represented
299
+ }
300
+ // Handle branded types - unwrap and continue
301
+ if (schema.constructor.name === 'VldBrand') {
302
+ return schemaToJSONSchema(schema.baseValidator, options);
303
+ }
304
+ // Handle readonly types
305
+ if (schema.constructor.name === 'VldReadonly') {
306
+ return schemaToJSONSchema(schema.baseValidator, options);
307
+ }
308
+ // Handle transform types
309
+ if (schema.constructor.name === 'VldTransform') {
310
+ return schemaToJSONSchema(schema._inner, options);
311
+ }
312
+ // Handle meta types - unwrap metadata
313
+ if (schema.constructor.name === 'VldMeta') {
314
+ const metaSchema = schema;
315
+ const result = schemaToJSONSchema(metaSchema.baseValidator, options);
316
+ if (options.includeMetadata !== false && metaSchema.metadata) {
317
+ const meta = metaSchema.metadata;
318
+ if (meta.title)
319
+ result.title = meta.title;
320
+ if (meta.description)
321
+ result.description = meta.description;
322
+ if (meta.examples && options.includeExamples)
323
+ result.examples = meta.examples;
324
+ if (meta.default !== undefined)
325
+ result.default = meta.default;
326
+ if (meta.deprecated)
327
+ result.deprecated = true;
328
+ if (meta.readOnly)
329
+ result.readOnly = true;
330
+ if (meta.writeOnly)
331
+ result.writeOnly = true;
332
+ }
333
+ return result;
334
+ }
335
+ // Handle refine/superRefine types
336
+ if (schema.constructor.name === 'VldRefine' || schema.constructor.name === 'VldSuperRefine') {
337
+ return schemaToJSONSchema(schema._inner || schema._baseValidator, options);
338
+ }
339
+ // Handle pipe types
340
+ if (schema.constructor.name === 'VldPipe') {
341
+ return schemaToJSONSchema(schema._next || schema.second, options);
342
+ }
343
+ // Handle default/catch types
344
+ if (schema.constructor.name === 'VldDefault' || schema.constructor.name === 'VldCatch') {
345
+ return schemaToJSONSchema(schema._inner || schema._baseValidator, options);
346
+ }
347
+ // Handle preprocess types
348
+ if (schema.constructor.name === 'VldPreprocess') {
349
+ return schemaToJSONSchema(schema._schema, options);
350
+ }
351
+ // Handle string format validators
352
+ if (schema.constructor.name === 'VldStringFormat') {
353
+ const formatSchema = schema;
354
+ return { type: 'string', format: formatSchema._format };
355
+ }
356
+ // Fallback for unknown types
357
+ return {};
358
+ }
359
+ /**
360
+ * Build string JSON Schema
361
+ */
362
+ function buildStringSchema(_target) {
363
+ return { type: 'string' };
364
+ }
365
+ /**
366
+ * Build number JSON Schema from VLD number schema
367
+ */
368
+ function buildNumberSchema(schema, _target) {
369
+ const config = schema.config || {};
370
+ const checks = config.checks || [];
371
+ const result = { type: 'number' };
372
+ for (const check of checks) {
373
+ // Try to extract constraints from closures
374
+ const checkStr = check.toString();
375
+ if (checkStr.includes('>=') || checkStr.includes('min')) {
376
+ result.minimum = 0; // Default, actual value is in closure
377
+ }
378
+ if (checkStr.includes('<=') || checkStr.includes('max')) {
379
+ result.maximum = 0; // Default, actual value is in closure
380
+ }
381
+ if (checkStr.includes('isInteger') || checkStr.includes('int')) {
382
+ result.type = 'integer';
383
+ }
384
+ if (checkStr.includes('isSafeInteger')) {
385
+ result.type = 'integer';
386
+ }
387
+ if (checkStr.includes('Number.isFinite')) ;
388
+ }
389
+ return result;
390
+ }
391
+ /**
392
+ * Build array JSON Schema
393
+ */
394
+ function buildArraySchema(schema, options) {
395
+ const inner = schema._item || schema._inner;
396
+ if (inner) {
397
+ return {
398
+ type: 'array',
399
+ items: toJSONSchema(inner, options)
400
+ };
401
+ }
402
+ return { type: 'array' };
403
+ }
404
+ /**
405
+ * Build object JSON Schema
406
+ */
407
+ function buildObjectSchema(schema, options) {
408
+ const shape = schema._shape || schema.shape;
409
+ if (!shape)
410
+ return { type: 'object' };
411
+ const properties = {};
412
+ const required = [];
413
+ for (const [key, value] of Object.entries(shape)) {
414
+ properties[key] = toJSONSchema(value, options);
415
+ // VLD objects require all keys by default
416
+ if (schema._strict !== false) {
417
+ required.push(key);
418
+ }
419
+ }
420
+ const result = {
421
+ type: 'object',
422
+ properties
423
+ };
424
+ if (required.length > 0) {
425
+ result.required = required;
426
+ }
427
+ // Handle passthrough mode
428
+ if (schema._passthrough || schema._loose) {
429
+ result.additionalProperties = true;
430
+ }
431
+ else if (schema._strict) {
432
+ result.additionalProperties = false;
433
+ }
434
+ return result;
435
+ }
436
+ /**
437
+ * Build union JSON Schema
438
+ */
439
+ function buildUnionSchema(schema, options) {
440
+ const validators = schema._validators || schema._options || [];
441
+ return {
442
+ anyOf: validators.map((v) => toJSONSchema(v, options))
443
+ };
444
+ }
445
+ /**
446
+ * Build literal JSON Schema
447
+ */
448
+ function buildLiteralSchema(schema) {
449
+ const value = schema._value || schema.value;
450
+ if (value === null)
451
+ return { type: 'null' };
452
+ if (typeof value === 'string')
453
+ return { type: 'string', const: value };
454
+ if (typeof value === 'number')
455
+ return { type: 'number', const: value };
456
+ if (typeof value === 'boolean')
457
+ return { type: 'boolean', const: value };
458
+ return { const: value };
459
+ }
460
+ /**
461
+ * Build enum JSON Schema
462
+ */
463
+ function buildEnumSchema(schema) {
464
+ const values = schema._values || schema.values;
465
+ if (Array.isArray(values)) {
466
+ return { enum: [...values] };
467
+ }
468
+ return {};
469
+ }
470
+ /**
471
+ * Build record JSON Schema
472
+ */
473
+ function buildRecordSchema(schema, options) {
474
+ const valueValidator = schema._value || schema._inner;
475
+ if (valueValidator) {
476
+ return {
477
+ type: 'object',
478
+ additionalProperties: toJSONSchema(valueValidator, options)
479
+ };
480
+ }
481
+ return { type: 'object' };
482
+ }
483
+ /**
484
+ * Build tuple JSON Schema
485
+ */
486
+ function buildTupleSchema(schema, options) {
487
+ const items = schema._items || schema.items;
488
+ if (!items || !Array.isArray(items)) {
489
+ return { type: 'array' };
490
+ }
491
+ return {
492
+ type: 'array',
493
+ items: items.map((item) => toJSONSchema(item, options)),
494
+ minItems: items.length,
495
+ maxItems: items.length
496
+ };
497
+ }
498
+ /**
499
+ * Build intersection JSON Schema
500
+ */
501
+ function buildIntersectionSchema(schema, options) {
502
+ const first = schema._first || schema.first;
503
+ const second = schema._second || schema.second;
504
+ const schemas = [];
505
+ if (first)
506
+ schemas.push(toJSONSchema(first, options));
507
+ if (second)
508
+ schemas.push(toJSONSchema(second, options));
509
+ if (schemas.length === 0)
510
+ return {};
511
+ if (schemas.length === 1)
512
+ return schemas[0];
513
+ return { allOf: schemas };
514
+ }
515
+ /**
516
+ * Build optional JSON Schema
517
+ */
518
+ function buildOptionalSchema(schema, options) {
519
+ const inner = schema._inner || schema._baseValidator;
520
+ if (!inner)
521
+ return {};
522
+ const result = toJSONSchema(inner, options);
523
+ // Remove from required array - but we don't track required here
524
+ return result;
525
+ }
526
+ /**
527
+ * Build nullable JSON Schema
528
+ */
529
+ function buildNullableSchema(schema, options) {
530
+ const inner = schema._inner || schema._baseValidator;
531
+ if (!inner)
532
+ return { type: 'null' };
533
+ const result = toJSONSchema(inner, options);
534
+ if (typeof result.type === 'string') {
535
+ return { type: [result.type, 'null'] };
536
+ }
537
+ else if (Array.isArray(result.type)) {
538
+ result.type.push('null');
539
+ return result;
540
+ }
541
+ return {
542
+ anyOf: [result, { type: 'null' }]
543
+ };
544
+ }
545
+ /**
546
+ * Build nullish JSON Schema
547
+ */
548
+ function buildNullishSchema(schema, options) {
549
+ const inner = schema._inner || schema._baseValidator;
550
+ if (!inner)
551
+ return {};
552
+ return toJSONSchema(inner, options);
553
+ }
554
+ /**
555
+ * Build exactOptional JSON Schema
556
+ */
557
+ function buildExactOptionalSchema(schema, options) {
558
+ const inner = schema._inner || schema._baseValidator;
559
+ if (!inner)
560
+ return {};
561
+ return toJSONSchema(inner, options);
562
+ }
563
+ /**
564
+ * Internal function to convert JSON Schema to VLD schema
565
+ */
566
+ function jsonSchemaToVLD(json) {
567
+ // This is a simplified implementation
568
+ // Full implementation would recursively handle all JSON Schema types
569
+ const VldString = require('../validators/string').VldString;
570
+ const VldNumber = require('../validators/number').VldNumber;
571
+ const VldBoolean = require('../validators/boolean').VldBoolean;
572
+ const VldObject = require('../validators/object').VldObject;
573
+ const VldArray = require('../validators/array').VldArray;
574
+ const VldUnion = require('../validators/union').VldUnion;
575
+ const VldLiteral = require('../validators/literal').VldLiteral;
576
+ const VldEnum = require('../validators/enum').VldEnum;
577
+ const VldNull = require('../validators/null').VldNull;
578
+ const VldAny = require('../validators/any').VldAny;
579
+ const VldRecord = require('../validators/record').VldRecord;
580
+ // Handle $ref
581
+ if (json.$ref) {
582
+ // For now, return any - full $ref handling requires registry
583
+ return VldAny.create();
584
+ }
585
+ // Handle anyOf/oneOf (union)
586
+ if (json.anyOf || json.oneOf) {
587
+ const options = (json.anyOf || json.oneOf)
588
+ .map((s) => jsonSchemaToVLD(s))
589
+ .filter(Boolean);
590
+ if (options.length > 0) {
591
+ return VldUnion.create(...options);
592
+ }
593
+ }
594
+ // Handle allOf (intersection)
595
+ if (json.allOf) {
596
+ // For intersection, we'd need VldIntersection
597
+ const first = jsonSchemaToVLD(json.allOf[0]);
598
+ if (json.allOf.length > 1) {
599
+ const second = jsonSchemaToVLD({ allOf: json.allOf.slice(1) });
600
+ const VldIntersection = require('../validators/intersection').VldIntersection;
601
+ return VldIntersection.create(first, second);
602
+ }
603
+ return first;
604
+ }
605
+ // Handle not
606
+ if (json.not) {
607
+ // For negation, we need special handling
608
+ return VldAny.create();
609
+ }
610
+ // Handle const
611
+ if (json.const !== undefined) {
612
+ return VldLiteral.create(json.const);
613
+ }
614
+ // Handle enum
615
+ if (json.enum) {
616
+ return VldEnum.create(json.enum);
617
+ }
618
+ // Handle type
619
+ const type = json.type;
620
+ if (type === 'string' || type === undefined) {
621
+ const s = VldString.create();
622
+ if (json.minLength)
623
+ s.minLength = json.minLength;
624
+ if (json.maxLength)
625
+ s.maxLength = json.maxLength;
626
+ if (json.pattern)
627
+ s.pattern = json.pattern;
628
+ if (json.format) {
629
+ // Map JSON Schema formats to VLD validators
630
+ switch (json.format) {
631
+ case 'date-time':
632
+ case 'date':
633
+ case 'time':
634
+ // Would need DateTime validator
635
+ break;
636
+ case 'email':
637
+ const email = require('../validators/string-formats').email;
638
+ return email();
639
+ case 'uri':
640
+ case 'uri-reference':
641
+ const httpUrl = require('../validators/string-formats').httpUrl;
642
+ return httpUrl();
643
+ case 'uuid':
644
+ const uuid = require('../validators/string-formats').uuid;
645
+ return uuid();
646
+ }
647
+ }
648
+ return s;
649
+ }
650
+ if (type === 'number' || type === 'integer') {
651
+ const n = VldNumber.create();
652
+ if (type === 'integer')
653
+ n.int();
654
+ if (json.minimum !== undefined)
655
+ n.min(json.minimum);
656
+ if (json.maximum !== undefined)
657
+ n.max(json.maximum);
658
+ if (json.exclusiveMinimum !== undefined)
659
+ n.gt(json.exclusiveMinimum);
660
+ if (json.exclusiveMaximum !== undefined)
661
+ n.lt(json.exclusiveMaximum);
662
+ if (json.multipleOf !== undefined)
663
+ n.multipleOf(json.multipleOf);
664
+ return n;
665
+ }
666
+ if (type === 'boolean') {
667
+ return VldBoolean.create();
668
+ }
669
+ if (type === 'array') {
670
+ if (json.items && !Array.isArray(json.items)) {
671
+ return VldArray.create(jsonSchemaToVLD(json.items));
672
+ }
673
+ return VldArray.create(VldAny.create());
674
+ }
675
+ if (type === 'object') {
676
+ if (json.properties) {
677
+ const shape = {};
678
+ const required = json.required || [];
679
+ for (const [key, propSchema] of Object.entries(json.properties)) {
680
+ shape[key] = jsonSchemaToVLD(propSchema);
681
+ }
682
+ let obj = VldObject.create(shape);
683
+ if (!required.length) {
684
+ // If no required fields, make all optional
685
+ for (const key of Object.keys(shape)) {
686
+ if (!required.includes(key)) ;
687
+ }
688
+ }
689
+ if (json.additionalProperties === false) {
690
+ obj = obj.strict();
691
+ }
692
+ else if (json.additionalProperties === true) {
693
+ obj = obj.passthrough();
694
+ }
695
+ else if (json.additionalProperties) {
696
+ // additionalProperties is a schema
697
+ const valueSchema = jsonSchemaToVLD(json.additionalProperties);
698
+ obj = VldRecord.create(valueSchema);
699
+ }
700
+ return obj;
701
+ }
702
+ // Empty object schema
703
+ return VldObject.create({});
704
+ }
705
+ if (type === 'null') {
706
+ return VldNull.create();
707
+ }
708
+ if (Array.isArray(type)) {
709
+ // Union of types
710
+ const options = type.map((t) => {
711
+ return jsonSchemaToVLD({ ...json, type: t });
712
+ });
713
+ if (options.length > 0) {
714
+ return VldUnion.create(...options);
715
+ }
716
+ }
717
+ // Fallback to any
718
+ return VldAny.create();
719
+ }
720
+
194
721
  /**
195
722
  * VLD - Fast, Type-Safe Validation Library
196
723
  * Zero dependencies, blazing fast performance
@@ -216,6 +743,11 @@ const v = {
216
743
  number: () => VldNumber.create(),
217
744
  int: () => VldNumber.create().int(),
218
745
  int32: () => VldNumber.create().int().min(-2147483648).max(2147483647),
746
+ uint32: () => VldNumber.create().uint32(),
747
+ uint64: () => VldNumber.create().uint64(),
748
+ int64: () => VldNumber.create().int64(),
749
+ float32: () => VldNumber.create().float32(),
750
+ float64: () => VldNumber.create().float64(),
219
751
  boolean: () => VldBoolean.create(),
220
752
  date: () => VldDate.create(),
221
753
  bigint: () => VldBigInt.create(),
@@ -254,6 +786,7 @@ const v = {
254
786
  optional: (validator) => VldOptional.create(validator),
255
787
  nullable: (validator) => VldNullable.create(validator),
256
788
  nullish: (validator) => VldNullish.create(validator),
789
+ exactOptional: (validator) => VldExactOptional.create(validator),
257
790
  // Recursive schemas
258
791
  lazy: (schemaGetter) => VldLazy.create(schemaGetter),
259
792
  // JSON validator
@@ -302,6 +835,10 @@ const v = {
302
835
  duration: () => iso.duration(),
303
836
  },
304
837
  stringFormat: (name, validator) => stringFormat(name, validator),
838
+ // Zod v4 parity string formats
839
+ xid: () => xid(),
840
+ guid: () => guid(),
841
+ httpUrl: () => httpUrl(),
305
842
  // Template literal validator
306
843
  templateLiteral: (...components) => templateLiteral(...components),
307
844
  // Codec validators (binary data validators)
@@ -309,8 +846,10 @@ const v = {
309
846
  hexBytes: () => VldHex.create(),
310
847
  uint8Array: () => VldUint8Array.create(),
311
848
  // Codec factory
312
- codec: (inputValidator, outputValidator, transform) => VldCodec.create(inputValidator, outputValidator, transform)
849
+ codec: (inputValidator, outputValidator, transform) => VldCodec.create(inputValidator, outputValidator, transform),
850
+ // Promise validator (Zod v4 parity)
851
+ promise: (inner) => promise(inner)
313
852
  };
314
853
 
315
- export { VldIntersection, createLogger, createNoOpLogger, v as default, disableLogging, enableDebug, getLogger, initLogger, setLogLevel, v };
854
+ export { VldIntersection, createLogger, createNoOpLogger, v as default, disableLogging, enableDebug, fromJSONSchema, getLogger, initLogger, setLogLevel, toJSONSchema, v };
316
855
  //# sourceMappingURL=index.js.map