@forklaunch/validator 0.7.4 → 0.7.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.
- package/lib/__test__/utils/mockSchemaValidator.d.mts +2 -1
- package/lib/__test__/utils/mockSchemaValidator.d.ts +2 -1
- package/lib/index.d.mts +3 -2
- package/lib/index.d.ts +3 -2
- package/lib/{schema.types-DuGvAboK.d.mts → schema.types-bwuhfE1y.d.mts} +7 -6
- package/lib/{schema.types-DuGvAboK.d.ts → schema.types-bwuhfE1y.d.ts} +7 -6
- package/lib/src/typebox/index.d.mts +3 -2
- package/lib/src/typebox/index.d.ts +3 -2
- package/lib/src/zod/index.d.mts +3 -2
- package/lib/src/zod/index.d.ts +3 -2
- package/lib/src/zod/index.js +34 -34
- package/lib/src/zod/index.mjs +1 -1
- package/package.json +6 -6
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-
|
|
2
|
+
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-bwuhfE1y.mjs';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import '@sinclair/typebox/compiler';
|
|
6
6
|
import 'zod';
|
|
7
|
+
import 'zod/v3';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Creates a union type string from an array of string literals.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-
|
|
2
|
+
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-bwuhfE1y.js';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import '@sinclair/typebox/compiler';
|
|
6
6
|
import 'zod';
|
|
7
|
+
import 'zod/v3';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Creates a union type string from an array of string literals.
|
package/lib/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { P as ParseError } from './schema.types-
|
|
2
|
-
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-
|
|
1
|
+
import { P as ParseError } from './schema.types-bwuhfE1y.mjs';
|
|
2
|
+
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-bwuhfE1y.mjs';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import 'openapi3-ts/oas31';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import '@sinclair/typebox/compiler';
|
|
7
7
|
import 'zod';
|
|
8
|
+
import 'zod/v3';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Pretty print parsing errors.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { P as ParseError } from './schema.types-
|
|
2
|
-
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-
|
|
1
|
+
import { P as ParseError } from './schema.types-bwuhfE1y.js';
|
|
2
|
+
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-bwuhfE1y.js';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import 'openapi3-ts/oas31';
|
|
5
5
|
import '@sinclair/typebox';
|
|
6
6
|
import '@sinclair/typebox/compiler';
|
|
7
7
|
import 'zod';
|
|
8
|
+
import 'zod/v3';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Pretty print parsing errors.
|
|
@@ -2,7 +2,8 @@ import { Prettify } from '@forklaunch/common';
|
|
|
2
2
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
3
|
import { TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TString, TTransform, TNumber, TBoolean, TNull, TBigInt, TDate, TSymbol, TVoid, TUndefined, TAny, TUnknown, TNever, TKind, TObject, StaticDecode } from '@sinclair/typebox';
|
|
4
4
|
import { TypeCheck } from '@sinclair/typebox/compiler';
|
|
5
|
-
import {
|
|
5
|
+
import { ZodUnknown, ZodPipeline, ZodTypeAny, ZodEffects, ZodLiteral as ZodLiteral$1, ZodType as ZodType$1, ZodNever, z as z$1, ZodRawShape as ZodRawShape$1, ZodObject as ZodObject$2, ZodArray as ZodArray$1 } from 'zod';
|
|
6
|
+
import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise, ZodType, z } from 'zod/v3';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This module provides a TypeScript-based schema definition using the TypeBox library.
|
|
@@ -365,23 +366,23 @@ type ZodCatchall = ZodTypeAny;
|
|
|
365
366
|
*
|
|
366
367
|
* @template T - The type to check and possibly convert to an array schema.
|
|
367
368
|
*/
|
|
368
|
-
type ZodOuterArray<T> = T extends ZodObject<ZodObjectShape> ? ZodArray<T> : ZodNever;
|
|
369
|
+
type ZodOuterArray<T> = T extends ZodObject<ZodObjectShape> ? ZodArray$1<T> : ZodNever;
|
|
369
370
|
/**
|
|
370
371
|
* Represents the shape of a Zod object schema.
|
|
371
372
|
*/
|
|
372
|
-
type ZodObjectShape = ZodRawShape;
|
|
373
|
+
type ZodObjectShape = ZodRawShape$1;
|
|
373
374
|
/**
|
|
374
375
|
* Represents a Zod object schema type. If the type T is a Zod object shape, it will return the original ZodObject type of T. Otherwise, it returns ZodNever.
|
|
375
376
|
*
|
|
376
377
|
* @template T - The type to check and possibly convert to a Zod object schema.
|
|
377
378
|
*/
|
|
378
|
-
type ZodObject<T> = T extends ZodObjectShape ? ZodObject$
|
|
379
|
+
type ZodObject<T> = T extends ZodObjectShape ? ZodObject$2<T> : ZodNever;
|
|
379
380
|
/**
|
|
380
381
|
* Translates a Zod schema type T to its static type if T extends ZodCatchall. Otherwise, it returns ZodNever.
|
|
381
382
|
*
|
|
382
383
|
* @template T - The Zod schema type to translate.
|
|
383
384
|
*/
|
|
384
|
-
type ZodSchemaTranslate<T> = T extends ZodCatchall ? z.infer<T> : ZodNever;
|
|
385
|
+
type ZodSchemaTranslate<T> = T extends ZodCatchall ? z$1.infer<T> : ZodNever;
|
|
385
386
|
/**
|
|
386
387
|
* Represents an unboxed Zod object schema where each key can have an idiomatic schema.
|
|
387
388
|
*/
|
|
@@ -438,7 +439,7 @@ type UnionZodResolve<T extends ZodUnionContainer> = T extends [
|
|
|
438
439
|
* @template T - The Zod schema type to resolve.
|
|
439
440
|
* @template Depth - The current depth of the resolution.
|
|
440
441
|
*/
|
|
441
|
-
type ZodResolve<T, Depth extends number = 0> = Depth extends 28 ? ZodUnknown : T extends ZodPipeline<ZodTypeAny, infer R> ? R : T extends ZodEffects<infer R> ? R : T extends LiteralSchema ? ZodLiteral<T> : T extends ZodType ? T : T extends UnboxedZodObjectSchema ? ZodObject<{
|
|
442
|
+
type ZodResolve<T, Depth extends number = 0> = Depth extends 28 ? ZodUnknown : T extends ZodPipeline<ZodTypeAny, infer R> ? R : T extends ZodEffects<infer R> ? R : T extends LiteralSchema ? ZodLiteral$1<T> : T extends ZodType$1 ? T : T extends UnboxedZodObjectSchema ? ZodObject<{
|
|
442
443
|
[K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
|
|
443
444
|
}> extends infer R ? R : ZodNever : ZodNever;
|
|
444
445
|
/**
|
|
@@ -2,7 +2,8 @@ import { Prettify } from '@forklaunch/common';
|
|
|
2
2
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
3
|
import { TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TString, TTransform, TNumber, TBoolean, TNull, TBigInt, TDate, TSymbol, TVoid, TUndefined, TAny, TUnknown, TNever, TKind, TObject, StaticDecode } from '@sinclair/typebox';
|
|
4
4
|
import { TypeCheck } from '@sinclair/typebox/compiler';
|
|
5
|
-
import {
|
|
5
|
+
import { ZodUnknown, ZodPipeline, ZodTypeAny, ZodEffects, ZodLiteral as ZodLiteral$1, ZodType as ZodType$1, ZodNever, z as z$1, ZodRawShape as ZodRawShape$1, ZodObject as ZodObject$2, ZodArray as ZodArray$1 } from 'zod';
|
|
6
|
+
import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise, ZodType, z } from 'zod/v3';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This module provides a TypeScript-based schema definition using the TypeBox library.
|
|
@@ -365,23 +366,23 @@ type ZodCatchall = ZodTypeAny;
|
|
|
365
366
|
*
|
|
366
367
|
* @template T - The type to check and possibly convert to an array schema.
|
|
367
368
|
*/
|
|
368
|
-
type ZodOuterArray<T> = T extends ZodObject<ZodObjectShape> ? ZodArray<T> : ZodNever;
|
|
369
|
+
type ZodOuterArray<T> = T extends ZodObject<ZodObjectShape> ? ZodArray$1<T> : ZodNever;
|
|
369
370
|
/**
|
|
370
371
|
* Represents the shape of a Zod object schema.
|
|
371
372
|
*/
|
|
372
|
-
type ZodObjectShape = ZodRawShape;
|
|
373
|
+
type ZodObjectShape = ZodRawShape$1;
|
|
373
374
|
/**
|
|
374
375
|
* Represents a Zod object schema type. If the type T is a Zod object shape, it will return the original ZodObject type of T. Otherwise, it returns ZodNever.
|
|
375
376
|
*
|
|
376
377
|
* @template T - The type to check and possibly convert to a Zod object schema.
|
|
377
378
|
*/
|
|
378
|
-
type ZodObject<T> = T extends ZodObjectShape ? ZodObject$
|
|
379
|
+
type ZodObject<T> = T extends ZodObjectShape ? ZodObject$2<T> : ZodNever;
|
|
379
380
|
/**
|
|
380
381
|
* Translates a Zod schema type T to its static type if T extends ZodCatchall. Otherwise, it returns ZodNever.
|
|
381
382
|
*
|
|
382
383
|
* @template T - The Zod schema type to translate.
|
|
383
384
|
*/
|
|
384
|
-
type ZodSchemaTranslate<T> = T extends ZodCatchall ? z.infer<T> : ZodNever;
|
|
385
|
+
type ZodSchemaTranslate<T> = T extends ZodCatchall ? z$1.infer<T> : ZodNever;
|
|
385
386
|
/**
|
|
386
387
|
* Represents an unboxed Zod object schema where each key can have an idiomatic schema.
|
|
387
388
|
*/
|
|
@@ -438,7 +439,7 @@ type UnionZodResolve<T extends ZodUnionContainer> = T extends [
|
|
|
438
439
|
* @template T - The Zod schema type to resolve.
|
|
439
440
|
* @template Depth - The current depth of the resolution.
|
|
440
441
|
*/
|
|
441
|
-
type ZodResolve<T, Depth extends number = 0> = Depth extends 28 ? ZodUnknown : T extends ZodPipeline<ZodTypeAny, infer R> ? R : T extends ZodEffects<infer R> ? R : T extends LiteralSchema ? ZodLiteral<T> : T extends ZodType ? T : T extends UnboxedZodObjectSchema ? ZodObject<{
|
|
442
|
+
type ZodResolve<T, Depth extends number = 0> = Depth extends 28 ? ZodUnknown : T extends ZodPipeline<ZodTypeAny, infer R> ? R : T extends ZodEffects<infer R> ? R : T extends LiteralSchema ? ZodLiteral$1<T> : T extends ZodType$1 ? T : T extends UnboxedZodObjectSchema ? ZodObject<{
|
|
442
443
|
[K in keyof T]: ZodResolve<T[K], Increment<Depth>>;
|
|
443
444
|
}> extends infer R ? R : ZodNever : ZodNever;
|
|
444
445
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from '@sinclair/typebox';
|
|
2
|
-
import { T as TypeboxSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-
|
|
2
|
+
import { T as TypeboxSchemaValidator } from '../../schema.types-bwuhfE1y.mjs';
|
|
3
|
+
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-bwuhfE1y.mjs';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox/compiler';
|
|
7
7
|
import 'zod';
|
|
8
|
+
import 'zod/v3';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Factory function for creating a TypeboxSchemaValidator instance.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from '@sinclair/typebox';
|
|
2
|
-
import { T as TypeboxSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-
|
|
2
|
+
import { T as TypeboxSchemaValidator } from '../../schema.types-bwuhfE1y.js';
|
|
3
|
+
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-bwuhfE1y.js';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox/compiler';
|
|
7
7
|
import 'zod';
|
|
8
|
+
import 'zod/v3';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Factory function for creating a TypeboxSchemaValidator instance.
|
package/lib/src/zod/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodDate, ZodEffects, ZodEnum, ZodFunction, ZodLiteral, ZodNever, ZodNull, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodRawShape, ZodRecord, ZodString, ZodSymbol, ZodTuple, ZodType, ZodTypeAny, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid } from 'zod';
|
|
2
|
-
import { Z as ZodSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-
|
|
2
|
+
import { Z as ZodSchemaValidator } from '../../schema.types-bwuhfE1y.mjs';
|
|
3
|
+
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-bwuhfE1y.mjs';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
import '@sinclair/typebox/compiler';
|
|
8
|
+
import 'zod/v3';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Factory function for creating a ZodSchemaValidator instance.
|
package/lib/src/zod/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodDate, ZodEffects, ZodEnum, ZodFunction, ZodLiteral, ZodNever, ZodNull, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodRawShape, ZodRecord, ZodString, ZodSymbol, ZodTuple, ZodType, ZodTypeAny, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid } from 'zod';
|
|
2
|
-
import { Z as ZodSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-
|
|
2
|
+
import { Z as ZodSchemaValidator } from '../../schema.types-bwuhfE1y.js';
|
|
3
|
+
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-bwuhfE1y.js';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox';
|
|
7
7
|
import '@sinclair/typebox/compiler';
|
|
8
|
+
import 'zod/v3';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Factory function for creating a ZodSchemaValidator instance.
|
package/lib/src/zod/index.js
CHANGED
|
@@ -59,45 +59,45 @@ module.exports = __toCommonJS(zod_exports);
|
|
|
59
59
|
|
|
60
60
|
// src/zod/zodSchemaValidator.ts
|
|
61
61
|
var import_zod_openapi = require("@anatine/zod-openapi");
|
|
62
|
-
var
|
|
63
|
-
(0, import_zod_openapi.extendZodWithOpenApi)(
|
|
62
|
+
var import_v3 = require("zod/v3");
|
|
63
|
+
(0, import_zod_openapi.extendZodWithOpenApi)(import_v3.z);
|
|
64
64
|
var ZodSchemaValidator = class {
|
|
65
65
|
_Type = "Zod";
|
|
66
66
|
_SchemaCatchall;
|
|
67
67
|
_ValidSchemaObject;
|
|
68
|
-
string =
|
|
68
|
+
string = import_v3.z.string().openapi({
|
|
69
69
|
title: "String",
|
|
70
70
|
example: "a string"
|
|
71
71
|
});
|
|
72
|
-
uuid =
|
|
72
|
+
uuid = import_v3.z.string().uuid().openapi({
|
|
73
73
|
title: "UUID",
|
|
74
74
|
format: "uuid",
|
|
75
75
|
pattern: "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
|
|
76
76
|
example: "a8b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6"
|
|
77
77
|
});
|
|
78
|
-
email =
|
|
78
|
+
email = import_v3.z.string().email().openapi({
|
|
79
79
|
title: "Email",
|
|
80
80
|
format: "email",
|
|
81
81
|
pattern: `(?:[a-z0-9!#$%&'*+/=?^_{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_{|}~-]+)*|"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])`,
|
|
82
82
|
example: "a@b.com"
|
|
83
83
|
});
|
|
84
|
-
uri =
|
|
84
|
+
uri = import_v3.z.string().url().openapi({
|
|
85
85
|
title: "URI",
|
|
86
86
|
format: "uri",
|
|
87
87
|
pattern: "^[a-zA-Z][a-zA-Z\\d+-.]*:[^\\s]*$",
|
|
88
88
|
example: "https://forklaunch.com"
|
|
89
89
|
});
|
|
90
|
-
number =
|
|
90
|
+
number = import_v3.z.preprocess((value) => {
|
|
91
91
|
try {
|
|
92
92
|
return Number(value);
|
|
93
93
|
} catch {
|
|
94
94
|
return value;
|
|
95
95
|
}
|
|
96
|
-
},
|
|
96
|
+
}, import_v3.z.number()).openapi({
|
|
97
97
|
title: "Number",
|
|
98
98
|
example: 123
|
|
99
99
|
});
|
|
100
|
-
bigint =
|
|
100
|
+
bigint = import_v3.z.preprocess((value) => {
|
|
101
101
|
try {
|
|
102
102
|
if (value instanceof Date) {
|
|
103
103
|
return BigInt(value.getTime());
|
|
@@ -114,23 +114,23 @@ var ZodSchemaValidator = class {
|
|
|
114
114
|
} catch {
|
|
115
115
|
return value;
|
|
116
116
|
}
|
|
117
|
-
},
|
|
117
|
+
}, import_v3.z.bigint()).openapi({
|
|
118
118
|
title: "BigInt",
|
|
119
119
|
type: "integer",
|
|
120
120
|
format: "int64",
|
|
121
121
|
example: 123n
|
|
122
122
|
});
|
|
123
|
-
boolean =
|
|
123
|
+
boolean = import_v3.z.preprocess((val) => {
|
|
124
124
|
if (typeof val === "string") {
|
|
125
125
|
if (val.toLowerCase() === "true") return true;
|
|
126
126
|
if (val.toLowerCase() === "false") return false;
|
|
127
127
|
}
|
|
128
128
|
return val;
|
|
129
|
-
},
|
|
129
|
+
}, import_v3.z.boolean()).openapi({
|
|
130
130
|
title: "Boolean",
|
|
131
131
|
example: true
|
|
132
132
|
});
|
|
133
|
-
date =
|
|
133
|
+
date = import_v3.z.preprocess((value) => {
|
|
134
134
|
try {
|
|
135
135
|
switch (typeof value) {
|
|
136
136
|
case "string":
|
|
@@ -143,58 +143,58 @@ var ZodSchemaValidator = class {
|
|
|
143
143
|
} catch {
|
|
144
144
|
return value;
|
|
145
145
|
}
|
|
146
|
-
},
|
|
146
|
+
}, import_v3.z.date()).openapi({
|
|
147
147
|
title: "Date",
|
|
148
148
|
type: "string",
|
|
149
149
|
format: "date-time",
|
|
150
150
|
example: "2025-05-16T21:13:04.123Z"
|
|
151
151
|
});
|
|
152
|
-
symbol =
|
|
152
|
+
symbol = import_v3.z.symbol().openapi({
|
|
153
153
|
title: "Symbol",
|
|
154
154
|
example: Symbol("symbol")
|
|
155
155
|
});
|
|
156
|
-
nullish =
|
|
156
|
+
nullish = import_v3.z.union([import_v3.z.void(), import_v3.z.null(), import_v3.z.undefined()]).openapi({
|
|
157
157
|
title: "Nullish",
|
|
158
158
|
type: "null",
|
|
159
159
|
example: null
|
|
160
160
|
});
|
|
161
|
-
void =
|
|
161
|
+
void = import_v3.z.void().openapi({
|
|
162
162
|
title: "Void",
|
|
163
163
|
type: "null",
|
|
164
164
|
example: void 0
|
|
165
165
|
});
|
|
166
|
-
null =
|
|
166
|
+
null = import_v3.z.null().openapi({
|
|
167
167
|
title: "Null",
|
|
168
168
|
type: "null",
|
|
169
169
|
example: null
|
|
170
170
|
});
|
|
171
|
-
undefined =
|
|
171
|
+
undefined = import_v3.z.undefined().openapi({
|
|
172
172
|
title: "Undefined",
|
|
173
173
|
type: "null",
|
|
174
174
|
example: void 0
|
|
175
175
|
});
|
|
176
|
-
any =
|
|
176
|
+
any = import_v3.z.any().openapi({
|
|
177
177
|
title: "Any",
|
|
178
178
|
type: "object",
|
|
179
179
|
example: "any"
|
|
180
180
|
});
|
|
181
|
-
unknown =
|
|
181
|
+
unknown = import_v3.z.unknown().openapi({
|
|
182
182
|
title: "Unknown",
|
|
183
183
|
type: "object",
|
|
184
184
|
example: "unknown"
|
|
185
185
|
});
|
|
186
|
-
never =
|
|
186
|
+
never = import_v3.z.never().openapi({
|
|
187
187
|
title: "Never",
|
|
188
188
|
type: "null",
|
|
189
189
|
example: "never"
|
|
190
190
|
});
|
|
191
|
-
binary =
|
|
191
|
+
binary = import_v3.z.string().transform((v) => new TextEncoder().encode(v)).openapi({
|
|
192
192
|
title: "Binary",
|
|
193
193
|
type: "string",
|
|
194
194
|
format: "binary",
|
|
195
195
|
example: "a utf-8 encodable string"
|
|
196
196
|
});
|
|
197
|
-
file =
|
|
197
|
+
file = import_v3.z.string().transform((val) => {
|
|
198
198
|
return new Blob([val]);
|
|
199
199
|
}).openapi({
|
|
200
200
|
title: "File",
|
|
@@ -219,20 +219,20 @@ var ZodSchemaValidator = class {
|
|
|
219
219
|
*/
|
|
220
220
|
schemify(schema) {
|
|
221
221
|
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
222
|
-
return
|
|
222
|
+
return import_v3.z.literal(schema);
|
|
223
223
|
}
|
|
224
|
-
if (schema instanceof
|
|
224
|
+
if (schema instanceof import_v3.ZodType) {
|
|
225
225
|
return schema;
|
|
226
226
|
}
|
|
227
227
|
const newSchema = {};
|
|
228
228
|
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
229
|
-
if (schema[key] instanceof
|
|
229
|
+
if (schema[key] instanceof import_v3.ZodType) {
|
|
230
230
|
newSchema[key] = schema[key];
|
|
231
231
|
} else {
|
|
232
232
|
newSchema[key] = this.schemify(schema[key]);
|
|
233
233
|
}
|
|
234
234
|
});
|
|
235
|
-
return
|
|
235
|
+
return import_v3.z.object(newSchema);
|
|
236
236
|
}
|
|
237
237
|
/**
|
|
238
238
|
* Make a schema optional.
|
|
@@ -259,7 +259,7 @@ var ZodSchemaValidator = class {
|
|
|
259
259
|
*/
|
|
260
260
|
union(schemas) {
|
|
261
261
|
const resolvedSchemas = schemas.map((schema) => this.schemify(schema));
|
|
262
|
-
return
|
|
262
|
+
return import_v3.z.union(
|
|
263
263
|
resolvedSchemas
|
|
264
264
|
);
|
|
265
265
|
}
|
|
@@ -269,7 +269,7 @@ var ZodSchemaValidator = class {
|
|
|
269
269
|
* @returns {ZodLiteral<ZodResolve<T>>} The literal schema.
|
|
270
270
|
*/
|
|
271
271
|
literal(value) {
|
|
272
|
-
return
|
|
272
|
+
return import_v3.z.literal(value);
|
|
273
273
|
}
|
|
274
274
|
/**
|
|
275
275
|
* Create an enum schema.
|
|
@@ -290,7 +290,7 @@ var ZodSchemaValidator = class {
|
|
|
290
290
|
function_(args, returnType) {
|
|
291
291
|
const schemaArgs = args.map((schema) => this.schemify(schema));
|
|
292
292
|
const schemaReturnType = this.schemify(returnType);
|
|
293
|
-
return
|
|
293
|
+
return import_v3.z.function(import_v3.z.tuple(schemaArgs), schemaReturnType);
|
|
294
294
|
}
|
|
295
295
|
/**
|
|
296
296
|
* Create a record schema.
|
|
@@ -301,7 +301,7 @@ var ZodSchemaValidator = class {
|
|
|
301
301
|
record(key, value) {
|
|
302
302
|
const keySchema = this.schemify(key);
|
|
303
303
|
const valueSchema = this.schemify(value);
|
|
304
|
-
return
|
|
304
|
+
return import_v3.z.record(keySchema, valueSchema);
|
|
305
305
|
}
|
|
306
306
|
/**
|
|
307
307
|
* Create a promise schema.
|
|
@@ -309,7 +309,7 @@ var ZodSchemaValidator = class {
|
|
|
309
309
|
* @returns {ZodPromise<ZodResolve<T>>} The promise schema.
|
|
310
310
|
*/
|
|
311
311
|
promise(schema) {
|
|
312
|
-
return
|
|
312
|
+
return import_v3.z.promise(this.schemify(schema));
|
|
313
313
|
}
|
|
314
314
|
/**
|
|
315
315
|
* Checks if a value is a Zod schema.
|
|
@@ -317,7 +317,7 @@ var ZodSchemaValidator = class {
|
|
|
317
317
|
* @returns {boolean} True if the value is a Zod schema.
|
|
318
318
|
*/
|
|
319
319
|
isSchema(value) {
|
|
320
|
-
return value instanceof
|
|
320
|
+
return value instanceof import_v3.ZodType;
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
323
323
|
* Checks if a value is an instance of a Zod schema.
|
package/lib/src/zod/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/validator",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Schema validator for ForkLaunch components.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -60,14 +60,14 @@
|
|
|
60
60
|
"dependencies": {
|
|
61
61
|
"@anatine/zod-openapi": "^2.2.8",
|
|
62
62
|
"@sinclair/typebox": "^0.34.37",
|
|
63
|
-
"zod": "^3.25.
|
|
64
|
-
"@forklaunch/common": "0.4.
|
|
63
|
+
"zod": "^3.25.76",
|
|
64
|
+
"@forklaunch/common": "0.4.3"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@eslint/js": "^9.30.1",
|
|
68
68
|
"@types/jest": "^30.0.0",
|
|
69
|
-
"@types/node": "^24.0.
|
|
70
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
69
|
+
"@types/node": "^24.0.12",
|
|
70
|
+
"@typescript/native-preview": "7.0.0-dev.20250709.1",
|
|
71
71
|
"@vitest/coverage-v8": "^3.2.4",
|
|
72
72
|
"eslint-config-prettier": "^10.1.5",
|
|
73
73
|
"eslint-plugin-prettier": "^5.5.1",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"ts-node": "^10.9.2",
|
|
79
79
|
"tsup": "^8.5.0",
|
|
80
80
|
"typedoc": "^0.28.7",
|
|
81
|
-
"typescript-eslint": "^8.
|
|
81
|
+
"typescript-eslint": "^8.36.0"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsgo --noEmit && tsup index.ts src/typebox/index.ts src/zod/index.ts __test__/utils/mockSchemaValidator.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",
|