@temporary-name/zod 1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8 → 1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1
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/dist/index.d.mts +39 -26
- package/dist/index.d.ts +39 -26
- package/dist/index.mjs +112 -53
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -26,6 +26,9 @@ declare const ZodRealError: core.$constructor<ZodError>;
|
|
|
26
26
|
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
|
|
27
27
|
type IssueData = core.$ZodRawIssue;
|
|
28
28
|
|
|
29
|
+
interface ParseContext extends core.ParseContextInternal<core.$ZodIssue> {
|
|
30
|
+
parseType?: 'query' | 'body' | 'path' | 'header' | 'output';
|
|
31
|
+
}
|
|
29
32
|
type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
|
|
30
33
|
type ZodSafeParseSuccess<T> = {
|
|
31
34
|
success: true;
|
|
@@ -37,24 +40,24 @@ type ZodSafeParseError<T> = {
|
|
|
37
40
|
data?: never;
|
|
38
41
|
error: ZodError<T>;
|
|
39
42
|
};
|
|
40
|
-
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
43
|
+
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
41
44
|
callee?: core.util.AnyFunc;
|
|
42
45
|
Err?: core.$ZodErrorClass;
|
|
43
46
|
}) => core.output<T>;
|
|
44
|
-
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
47
|
+
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
45
48
|
callee?: core.util.AnyFunc;
|
|
46
49
|
Err?: core.$ZodErrorClass;
|
|
47
50
|
}) => Promise<core.output<T>>;
|
|
48
|
-
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
49
|
-
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
50
|
-
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
51
|
-
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
52
|
-
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
53
|
-
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
54
|
-
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
55
|
-
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
56
|
-
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
57
|
-
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
51
|
+
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
52
|
+
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
53
|
+
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => core.input<T>;
|
|
54
|
+
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => core.output<T>;
|
|
55
|
+
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<core.input<T>>;
|
|
56
|
+
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<core.output<T>>;
|
|
57
|
+
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.input<T>>;
|
|
58
|
+
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
59
|
+
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.input<T>>>;
|
|
60
|
+
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
58
61
|
|
|
59
62
|
type IsGateEnabled = (gate: string) => boolean;
|
|
60
63
|
declare const gatingContext: AsyncLocalStorage<IsGateEnabled>;
|
|
@@ -76,6 +79,15 @@ interface KrustyGate<T extends core.SomeType = core.$ZodType, K extends KrustyIn
|
|
|
76
79
|
declare const KrustyGate: core.$constructor<KrustyGate>;
|
|
77
80
|
declare function gate<T extends core.SomeType, K extends KrustyInternals>(innerType: T, gateName: K['gateNames']): KrustyGate<T, K>;
|
|
78
81
|
|
|
82
|
+
interface KrustyISODateTime extends KrustyStringFormat {
|
|
83
|
+
_zod: core.$ZodISODateTimeInternals;
|
|
84
|
+
}
|
|
85
|
+
declare const KrustyISODateTime: core.$constructor<KrustyISODateTime>;
|
|
86
|
+
interface KrustyISODate extends KrustyStringFormat {
|
|
87
|
+
_zod: core.$ZodISODateInternals;
|
|
88
|
+
}
|
|
89
|
+
declare const KrustyISODate: core.$constructor<KrustyISODate>;
|
|
90
|
+
|
|
79
91
|
type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
|
80
92
|
[K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
|
|
81
93
|
};
|
|
@@ -164,6 +176,13 @@ interface KrustyType<out Output = unknown, out Input = unknown, out Internals ex
|
|
|
164
176
|
or<T extends core.SomeType>(option: T): KrustyUnion<[this, T], KInternals>;
|
|
165
177
|
and<T extends core.SomeType>(incoming: T): KrustyIntersection<this, T, KInternals>;
|
|
166
178
|
transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): KrustyPipe<this, KrustyTransform<Awaited<NewOut>, core.output<this>>, KInternals>;
|
|
179
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
|
|
180
|
+
describe(description: string): this;
|
|
181
|
+
description?: string;
|
|
182
|
+
/** Returns the metadata associated with this instance in `z.globalRegistry` */
|
|
183
|
+
meta(): core.$replace<core.GlobalMeta, this> | undefined;
|
|
184
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
|
|
185
|
+
meta(data: core.$replace<core.GlobalMeta, this>): this;
|
|
167
186
|
}
|
|
168
187
|
declare const KrustyType: core.$constructor<_KrustyType>;
|
|
169
188
|
interface _KrustyString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>, K extends KrustyInternals = KrustyInternals> extends _KrustyType<T, K> {
|
|
@@ -234,14 +253,6 @@ interface KrustyString<K extends KrustyInternals = KrustyInternals> extends _Kru
|
|
|
234
253
|
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
235
254
|
/** @deprecated Use `z.e164()` instead. */
|
|
236
255
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
237
|
-
/** @deprecated Use `z.iso.datetime()` instead. */
|
|
238
|
-
datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
|
|
239
|
-
/** @deprecated Use `z.iso.date()` instead. */
|
|
240
|
-
date(params?: string | core.$ZodCheckISODateParams): this;
|
|
241
|
-
/** @deprecated Use `z.iso.time()` instead. */
|
|
242
|
-
time(params?: string | core.$ZodCheckISOTimeParams): this;
|
|
243
|
-
/** @deprecated Use `z.iso.duration()` instead. */
|
|
244
|
-
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
245
256
|
}
|
|
246
257
|
declare const KrustyString: core.$constructor<KrustyString>;
|
|
247
258
|
declare function string<K extends KrustyInternals = KrustyInternals>(params?: string | core.$ZodStringParams): KrustyString<K>;
|
|
@@ -368,8 +379,6 @@ interface _KrustyNumber<Internals extends core.$ZodNumberInternals = core.$ZodNu
|
|
|
368
379
|
max(value: number, params?: string | core.$ZodCheckLessThanParams): this;
|
|
369
380
|
/** Consider `z.int()` instead. This API is considered *legacy*; it will never be removed but a better alternative exists. */
|
|
370
381
|
int(params?: string | core.$ZodCheckNumberFormatParams): this;
|
|
371
|
-
/** @deprecated This is now identical to `.int()`. Only numbers in the safe integer range are accepted. */
|
|
372
|
-
safe(params?: string | core.$ZodCheckNumberFormatParams): this;
|
|
373
382
|
positive(params?: string | core.$ZodCheckGreaterThanParams): this;
|
|
374
383
|
nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
|
|
375
384
|
negative(params?: string | core.$ZodCheckLessThanParams): this;
|
|
@@ -486,7 +495,10 @@ interface _KrustyDate<T extends core.$ZodDateInternals = core.$ZodDateInternals,
|
|
|
486
495
|
interface KrustyDate<K extends KrustyInternals = KrustyInternals> extends _KrustyDate<core.$ZodDateInternals<Date>, K> {
|
|
487
496
|
}
|
|
488
497
|
declare const KrustyDate: core.$constructor<KrustyDate>;
|
|
489
|
-
|
|
498
|
+
type KrustyDateCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODate, KrustyDate, K>;
|
|
499
|
+
declare function date<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
500
|
+
type KrustyDateTimeCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODateTime, KrustyDate, K>;
|
|
501
|
+
declare function datetime<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateTimeParams)): KrustyDateTimeCodec<K>;
|
|
490
502
|
interface KrustyArray<T extends core.SomeType = core.$ZodType, K extends KrustyInternals = KrustyInternals> extends _KrustyType<core.$ZodArrayInternals<T>, K>, core.$ZodArray<T> {
|
|
491
503
|
element: T;
|
|
492
504
|
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
@@ -717,7 +729,8 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
717
729
|
union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): KrustyUnion<T, K>;
|
|
718
730
|
discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): KrustyDiscriminatedUnion<Types, Disc, K>;
|
|
719
731
|
object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): KrustyObject<core.util.Writeable<T>, core.$strip, K>;
|
|
720
|
-
date(params?: string | core.$ZodDateParams):
|
|
732
|
+
date(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
733
|
+
datetime(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateTimeCodec<K>;
|
|
721
734
|
any(): KrustyAny<K>;
|
|
722
735
|
unknown(): KrustyUnknown<K>;
|
|
723
736
|
never(params?: string | core.$ZodNeverParams): KrustyNever<K>;
|
|
@@ -725,5 +738,5 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
725
738
|
json(params?: string | core.$ZodCustomParams): KrustyJSONSchema<K>;
|
|
726
739
|
}
|
|
727
740
|
|
|
728
|
-
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
729
|
-
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
|
741
|
+
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
742
|
+
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyDateCodec, KrustyDateTimeCodec, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, ParseContext, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
package/dist/index.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ declare const ZodRealError: core.$constructor<ZodError>;
|
|
|
26
26
|
/** @deprecated Use `z.core.$ZodRawIssue` instead. */
|
|
27
27
|
type IssueData = core.$ZodRawIssue;
|
|
28
28
|
|
|
29
|
+
interface ParseContext extends core.ParseContextInternal<core.$ZodIssue> {
|
|
30
|
+
parseType?: 'query' | 'body' | 'path' | 'header' | 'output';
|
|
31
|
+
}
|
|
29
32
|
type ZodSafeParseResult<T> = ZodSafeParseSuccess<T> | ZodSafeParseError<T>;
|
|
30
33
|
type ZodSafeParseSuccess<T> = {
|
|
31
34
|
success: true;
|
|
@@ -37,24 +40,24 @@ type ZodSafeParseError<T> = {
|
|
|
37
40
|
data?: never;
|
|
38
41
|
error: ZodError<T>;
|
|
39
42
|
};
|
|
40
|
-
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
43
|
+
declare const parse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
41
44
|
callee?: core.util.AnyFunc;
|
|
42
45
|
Err?: core.$ZodErrorClass;
|
|
43
46
|
}) => core.output<T>;
|
|
44
|
-
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
47
|
+
declare const parseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext, _params?: {
|
|
45
48
|
callee?: core.util.AnyFunc;
|
|
46
49
|
Err?: core.$ZodErrorClass;
|
|
47
50
|
}) => Promise<core.output<T>>;
|
|
48
|
-
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
49
|
-
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?:
|
|
50
|
-
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
51
|
-
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
52
|
-
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
53
|
-
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
54
|
-
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
55
|
-
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
56
|
-
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?:
|
|
57
|
-
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?:
|
|
51
|
+
declare const safeParse: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
52
|
+
declare const safeParseAsync: <T extends core.$ZodType>(schema: T, value: unknown, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
53
|
+
declare const encode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => core.input<T>;
|
|
54
|
+
declare const decode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => core.output<T>;
|
|
55
|
+
declare const encodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<core.input<T>>;
|
|
56
|
+
declare const decodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<core.output<T>>;
|
|
57
|
+
declare const safeEncode: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.input<T>>;
|
|
58
|
+
declare const safeDecode: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => ZodSafeParseResult<core.output<T>>;
|
|
59
|
+
declare const safeEncodeAsync: <T extends core.$ZodType>(schema: T, value: core.output<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.input<T>>>;
|
|
60
|
+
declare const safeDecodeAsync: <T extends core.$ZodType>(schema: T, value: core.input<T>, _ctx?: ParseContext) => Promise<ZodSafeParseResult<core.output<T>>>;
|
|
58
61
|
|
|
59
62
|
type IsGateEnabled = (gate: string) => boolean;
|
|
60
63
|
declare const gatingContext: AsyncLocalStorage<IsGateEnabled>;
|
|
@@ -76,6 +79,15 @@ interface KrustyGate<T extends core.SomeType = core.$ZodType, K extends KrustyIn
|
|
|
76
79
|
declare const KrustyGate: core.$constructor<KrustyGate>;
|
|
77
80
|
declare function gate<T extends core.SomeType, K extends KrustyInternals>(innerType: T, gateName: K['gateNames']): KrustyGate<T, K>;
|
|
78
81
|
|
|
82
|
+
interface KrustyISODateTime extends KrustyStringFormat {
|
|
83
|
+
_zod: core.$ZodISODateTimeInternals;
|
|
84
|
+
}
|
|
85
|
+
declare const KrustyISODateTime: core.$constructor<KrustyISODateTime>;
|
|
86
|
+
interface KrustyISODate extends KrustyStringFormat {
|
|
87
|
+
_zod: core.$ZodISODateInternals;
|
|
88
|
+
}
|
|
89
|
+
declare const KrustyISODate: core.$constructor<KrustyISODate>;
|
|
90
|
+
|
|
79
91
|
type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
|
80
92
|
[K in keyof Ext]: K extends keyof Base ? core.output<Ext[K]> extends core.output<Base[K]> ? core.input<Ext[K]> extends core.input<Base[K]> ? Ext[K] : never : never : Ext[K];
|
|
81
93
|
};
|
|
@@ -164,6 +176,13 @@ interface KrustyType<out Output = unknown, out Input = unknown, out Internals ex
|
|
|
164
176
|
or<T extends core.SomeType>(option: T): KrustyUnion<[this, T], KInternals>;
|
|
165
177
|
and<T extends core.SomeType>(incoming: T): KrustyIntersection<this, T, KInternals>;
|
|
166
178
|
transform<NewOut>(transform: (arg: core.output<this>, ctx: core.$RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): KrustyPipe<this, KrustyTransform<Awaited<NewOut>, core.output<this>>, KInternals>;
|
|
179
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified description */
|
|
180
|
+
describe(description: string): this;
|
|
181
|
+
description?: string;
|
|
182
|
+
/** Returns the metadata associated with this instance in `z.globalRegistry` */
|
|
183
|
+
meta(): core.$replace<core.GlobalMeta, this> | undefined;
|
|
184
|
+
/** Returns a new instance that has been registered in `z.globalRegistry` with the specified metadata */
|
|
185
|
+
meta(data: core.$replace<core.GlobalMeta, this>): this;
|
|
167
186
|
}
|
|
168
187
|
declare const KrustyType: core.$constructor<_KrustyType>;
|
|
169
188
|
interface _KrustyString<T extends core.$ZodStringInternals<unknown> = core.$ZodStringInternals<unknown>, K extends KrustyInternals = KrustyInternals> extends _KrustyType<T, K> {
|
|
@@ -234,14 +253,6 @@ interface KrustyString<K extends KrustyInternals = KrustyInternals> extends _Kru
|
|
|
234
253
|
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
235
254
|
/** @deprecated Use `z.e164()` instead. */
|
|
236
255
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
237
|
-
/** @deprecated Use `z.iso.datetime()` instead. */
|
|
238
|
-
datetime(params?: string | core.$ZodCheckISODateTimeParams): this;
|
|
239
|
-
/** @deprecated Use `z.iso.date()` instead. */
|
|
240
|
-
date(params?: string | core.$ZodCheckISODateParams): this;
|
|
241
|
-
/** @deprecated Use `z.iso.time()` instead. */
|
|
242
|
-
time(params?: string | core.$ZodCheckISOTimeParams): this;
|
|
243
|
-
/** @deprecated Use `z.iso.duration()` instead. */
|
|
244
|
-
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
245
256
|
}
|
|
246
257
|
declare const KrustyString: core.$constructor<KrustyString>;
|
|
247
258
|
declare function string<K extends KrustyInternals = KrustyInternals>(params?: string | core.$ZodStringParams): KrustyString<K>;
|
|
@@ -368,8 +379,6 @@ interface _KrustyNumber<Internals extends core.$ZodNumberInternals = core.$ZodNu
|
|
|
368
379
|
max(value: number, params?: string | core.$ZodCheckLessThanParams): this;
|
|
369
380
|
/** Consider `z.int()` instead. This API is considered *legacy*; it will never be removed but a better alternative exists. */
|
|
370
381
|
int(params?: string | core.$ZodCheckNumberFormatParams): this;
|
|
371
|
-
/** @deprecated This is now identical to `.int()`. Only numbers in the safe integer range are accepted. */
|
|
372
|
-
safe(params?: string | core.$ZodCheckNumberFormatParams): this;
|
|
373
382
|
positive(params?: string | core.$ZodCheckGreaterThanParams): this;
|
|
374
383
|
nonnegative(params?: string | core.$ZodCheckGreaterThanParams): this;
|
|
375
384
|
negative(params?: string | core.$ZodCheckLessThanParams): this;
|
|
@@ -486,7 +495,10 @@ interface _KrustyDate<T extends core.$ZodDateInternals = core.$ZodDateInternals,
|
|
|
486
495
|
interface KrustyDate<K extends KrustyInternals = KrustyInternals> extends _KrustyDate<core.$ZodDateInternals<Date>, K> {
|
|
487
496
|
}
|
|
488
497
|
declare const KrustyDate: core.$constructor<KrustyDate>;
|
|
489
|
-
|
|
498
|
+
type KrustyDateCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODate, KrustyDate, K>;
|
|
499
|
+
declare function date<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
500
|
+
type KrustyDateTimeCodec<K extends KrustyInternals = KrustyInternals> = KrustyCodec<KrustyISODateTime, KrustyDate, K>;
|
|
501
|
+
declare function datetime<K extends KrustyInternals = KrustyInternals>(params?: string | (core.$ZodDateParams & core.$ZodISODateTimeParams)): KrustyDateTimeCodec<K>;
|
|
490
502
|
interface KrustyArray<T extends core.SomeType = core.$ZodType, K extends KrustyInternals = KrustyInternals> extends _KrustyType<core.$ZodArrayInternals<T>, K>, core.$ZodArray<T> {
|
|
491
503
|
element: T;
|
|
492
504
|
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
@@ -717,7 +729,8 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
717
729
|
union<const T extends readonly core.SomeType[]>(options: T, params?: string | core.$ZodUnionParams): KrustyUnion<T, K>;
|
|
718
730
|
discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): KrustyDiscriminatedUnion<Types, Disc, K>;
|
|
719
731
|
object<T extends core.$ZodLooseShape = Partial<Record<never, core.SomeType>>>(shape?: T, params?: string | core.$ZodObjectParams): KrustyObject<core.util.Writeable<T>, core.$strip, K>;
|
|
720
|
-
date(params?: string | core.$ZodDateParams):
|
|
732
|
+
date(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateCodec<K>;
|
|
733
|
+
datetime(params?: string | (core.$ZodDateParams & core.$ZodISODateParams)): KrustyDateTimeCodec<K>;
|
|
721
734
|
any(): KrustyAny<K>;
|
|
722
735
|
unknown(): KrustyUnknown<K>;
|
|
723
736
|
never(params?: string | core.$ZodNeverParams): KrustyNever<K>;
|
|
@@ -725,5 +738,5 @@ declare class SchemaClass<GateNames extends string = never, K extends KrustyInte
|
|
|
725
738
|
json(params?: string | core.$ZodCustomParams): KrustyJSONSchema<K>;
|
|
726
739
|
}
|
|
727
740
|
|
|
728
|
-
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
729
|
-
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
|
741
|
+
export { $ZodGate, KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
742
|
+
export type { $ZodGateDef, $ZodGateInternals, IsGateEnabled, IssueData, KrustyDateCodec, KrustyDateTimeCodec, KrustyFloat32, KrustyFloat64, KrustyInt, KrustyInt32, KrustyInternals, KrustyJSONSchema, KrustyJSONSchemaInternals, KrustyUInt32, ParseContext, SafeExtendShape, ZodIssue, ZodSafeParseError, ZodSafeParseResult, ZodSafeParseSuccess, _KrustyBigInt, _KrustyBoolean, _KrustyDate, _KrustyNumber, _KrustyType };
|
package/dist/index.mjs
CHANGED
|
@@ -56,51 +56,6 @@ const safeDecode = /* @__PURE__ */ core._safeDecode(ZodRealError);
|
|
|
56
56
|
const safeEncodeAsync = /* @__PURE__ */ core._safeEncodeAsync(ZodRealError);
|
|
57
57
|
const safeDecodeAsync = /* @__PURE__ */ core._safeDecodeAsync(ZodRealError);
|
|
58
58
|
|
|
59
|
-
const KrustyISODateTime = /* @__PURE__ */ core.$constructor(
|
|
60
|
-
"KrustyISODateTime",
|
|
61
|
-
(inst, def) => {
|
|
62
|
-
const coreInit = core.$ZodISODateTime.init;
|
|
63
|
-
coreInit(inst, def);
|
|
64
|
-
KrustyStringFormat.init(inst, def);
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
function datetime(params) {
|
|
68
|
-
return core._isoDateTime(KrustyISODateTime, params);
|
|
69
|
-
}
|
|
70
|
-
const KrustyISODate = /* @__PURE__ */ core.$constructor(
|
|
71
|
-
"KrustyISODate",
|
|
72
|
-
(inst, def) => {
|
|
73
|
-
const coreInit = core.$ZodISODate.init;
|
|
74
|
-
coreInit(inst, def);
|
|
75
|
-
KrustyStringFormat.init(inst, def);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
function date$1(params) {
|
|
79
|
-
return core._isoDate(KrustyISODate, params);
|
|
80
|
-
}
|
|
81
|
-
const KrustyISOTime = /* @__PURE__ */ core.$constructor(
|
|
82
|
-
"KrustyISOTime",
|
|
83
|
-
(inst, def) => {
|
|
84
|
-
const coreInit = core.$ZodISOTime.init;
|
|
85
|
-
coreInit(inst, def);
|
|
86
|
-
KrustyStringFormat.init(inst, def);
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
function time(params) {
|
|
90
|
-
return core._isoTime(KrustyISOTime, params);
|
|
91
|
-
}
|
|
92
|
-
const KrustyISODuration = /* @__PURE__ */ core.$constructor(
|
|
93
|
-
"KrustyISODuration",
|
|
94
|
-
(inst, def) => {
|
|
95
|
-
const coreInit = core.$ZodISODuration.init;
|
|
96
|
-
coreInit(inst, def);
|
|
97
|
-
KrustyStringFormat.init(inst, def);
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
function duration(params) {
|
|
101
|
-
return core._isoDuration(KrustyISODuration, params);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
59
|
const gatingContext = new AsyncLocalStorage();
|
|
105
60
|
function isGateIssueRaw(issue) {
|
|
106
61
|
return issue.code === "invalid_type" && issue.expected === "never" && issue.inst instanceof KrustyGate;
|
|
@@ -138,6 +93,29 @@ function gate(innerType, gateName) {
|
|
|
138
93
|
});
|
|
139
94
|
}
|
|
140
95
|
|
|
96
|
+
const KrustyISODateTime = /* @__PURE__ */ core.$constructor(
|
|
97
|
+
"KrustyISODateTime",
|
|
98
|
+
(inst, def) => {
|
|
99
|
+
const coreInit = core.$ZodISODateTime.init;
|
|
100
|
+
coreInit(inst, def);
|
|
101
|
+
KrustyStringFormat.init(inst, def);
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
function datetime$1(params) {
|
|
105
|
+
return core._isoDateTime(KrustyISODateTime, params);
|
|
106
|
+
}
|
|
107
|
+
const KrustyISODate = /* @__PURE__ */ core.$constructor(
|
|
108
|
+
"KrustyISODate",
|
|
109
|
+
(inst, def) => {
|
|
110
|
+
const coreInit = core.$ZodISODate.init;
|
|
111
|
+
coreInit(inst, def);
|
|
112
|
+
KrustyStringFormat.init(inst, def);
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
function date$1(params) {
|
|
116
|
+
return core._isoDate(KrustyISODate, params);
|
|
117
|
+
}
|
|
118
|
+
|
|
141
119
|
function handleGating(payload) {
|
|
142
120
|
for (let i = 0; i < payload.issues.length; i++) {
|
|
143
121
|
const issue = payload.issues[i];
|
|
@@ -280,6 +258,26 @@ const KrustyObject = /* @__PURE__ */ core.$constructor(
|
|
|
280
258
|
inst._zod.parse = (payload, ctx) => {
|
|
281
259
|
const input = payload.value;
|
|
282
260
|
const res = origParse(payload, ctx);
|
|
261
|
+
if (!def.catchall) {
|
|
262
|
+
const { parseType } = ctx;
|
|
263
|
+
if (parseType && parseType !== "output") {
|
|
264
|
+
const unrecognized = [];
|
|
265
|
+
const keySet = new Set(Object.keys(def.shape));
|
|
266
|
+
for (const key in input) {
|
|
267
|
+
if (!keySet.has(key)) {
|
|
268
|
+
unrecognized.push(key);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (unrecognized.length) {
|
|
272
|
+
payload.issues.push({
|
|
273
|
+
code: "unrecognized_keys",
|
|
274
|
+
keys: unrecognized,
|
|
275
|
+
input,
|
|
276
|
+
inst
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
283
281
|
if (res instanceof Promise) {
|
|
284
282
|
return res.then((r) => handleGating(input, r, ctx));
|
|
285
283
|
} else {
|
|
@@ -353,6 +351,25 @@ const KrustyType = /* @__PURE__ */ core.$constructor(
|
|
|
353
351
|
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
354
352
|
inst.default = (def2) => _default(inst, def2);
|
|
355
353
|
inst.prefault = (def2) => prefault(inst, def2);
|
|
354
|
+
inst.describe = (description) => {
|
|
355
|
+
const cl = inst.clone();
|
|
356
|
+
core.globalRegistry.add(cl, { description });
|
|
357
|
+
return cl;
|
|
358
|
+
};
|
|
359
|
+
Object.defineProperty(inst, "description", {
|
|
360
|
+
get() {
|
|
361
|
+
return core.globalRegistry.get(inst)?.description;
|
|
362
|
+
},
|
|
363
|
+
configurable: true
|
|
364
|
+
});
|
|
365
|
+
inst.meta = (...args) => {
|
|
366
|
+
if (args.length === 0) {
|
|
367
|
+
return core.globalRegistry.get(inst);
|
|
368
|
+
}
|
|
369
|
+
const cl = inst.clone();
|
|
370
|
+
core.globalRegistry.add(cl, args[0]);
|
|
371
|
+
return cl;
|
|
372
|
+
};
|
|
356
373
|
return inst;
|
|
357
374
|
}
|
|
358
375
|
);
|
|
@@ -411,10 +428,6 @@ const KrustyString = /* @__PURE__ */ core.$constructor(
|
|
|
411
428
|
inst.cidrv4 = (params) => inst.check(core._cidrv4(KrustyCIDRv4, params));
|
|
412
429
|
inst.cidrv6 = (params) => inst.check(core._cidrv6(KrustyCIDRv6, params));
|
|
413
430
|
inst.e164 = (params) => inst.check(core._e164(KrustyE164, params));
|
|
414
|
-
inst.datetime = (params) => inst.check(datetime(params));
|
|
415
|
-
inst.date = (params) => inst.check(date$1(params));
|
|
416
|
-
inst.time = (params) => inst.check(time(params));
|
|
417
|
-
inst.duration = (params) => inst.check(duration(params));
|
|
418
431
|
}
|
|
419
432
|
);
|
|
420
433
|
function string(params) {
|
|
@@ -687,7 +700,6 @@ const KrustyNumber = /* @__PURE__ */ core.$constructor(
|
|
|
687
700
|
inst.lte = (value, params) => inst.check(_lte(value, params));
|
|
688
701
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
689
702
|
inst.int = (params) => inst.check(int(params));
|
|
690
|
-
inst.safe = (params) => inst.check(int(params));
|
|
691
703
|
inst.positive = (params) => inst.check(_gt(0, params));
|
|
692
704
|
inst.nonnegative = (params) => inst.check(_gte(0, params));
|
|
693
705
|
inst.negative = (params) => inst.check(_lt(0, params));
|
|
@@ -701,6 +713,17 @@ const KrustyNumber = /* @__PURE__ */ core.$constructor(
|
|
|
701
713
|
inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
|
|
702
714
|
inst.isFinite = true;
|
|
703
715
|
inst.format = bag.format ?? null;
|
|
716
|
+
const origParse = inst._zod.parse;
|
|
717
|
+
inst._zod.parse = (payload, ctx) => {
|
|
718
|
+
const { parseType } = ctx;
|
|
719
|
+
if (parseType === "query" && typeof payload.value === "string") {
|
|
720
|
+
const value = Number(payload.value);
|
|
721
|
+
if (!Number.isNaN(value)) {
|
|
722
|
+
payload.value = value;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return origParse(payload, ctx);
|
|
726
|
+
};
|
|
704
727
|
}
|
|
705
728
|
);
|
|
706
729
|
function number(params) {
|
|
@@ -735,6 +758,28 @@ const KrustyBoolean = /* @__PURE__ */ core.$constructor(
|
|
|
735
758
|
const coreInit = core.$ZodBoolean.init;
|
|
736
759
|
coreInit(inst, def);
|
|
737
760
|
KrustyType.init(inst, def);
|
|
761
|
+
const origParse = inst._zod.parse;
|
|
762
|
+
inst._zod.parse = (payload, ctx) => {
|
|
763
|
+
const { parseType } = ctx;
|
|
764
|
+
if (parseType === "query") {
|
|
765
|
+
if (payload.value === "true") {
|
|
766
|
+
payload.value = true;
|
|
767
|
+
} else if (payload.value === "false") {
|
|
768
|
+
payload.value = false;
|
|
769
|
+
} else {
|
|
770
|
+
payload.issues.push({
|
|
771
|
+
code: "invalid_type",
|
|
772
|
+
expected: "boolean",
|
|
773
|
+
values: ["true", "false"],
|
|
774
|
+
input: payload.value,
|
|
775
|
+
inst,
|
|
776
|
+
continue: false
|
|
777
|
+
});
|
|
778
|
+
return payload;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return origParse(payload, ctx);
|
|
782
|
+
};
|
|
738
783
|
}
|
|
739
784
|
);
|
|
740
785
|
function boolean(params) {
|
|
@@ -873,7 +918,19 @@ const KrustyDate = /* @__PURE__ */ core.$constructor(
|
|
|
873
918
|
}
|
|
874
919
|
);
|
|
875
920
|
function date(params) {
|
|
876
|
-
return core._date(KrustyDate, params)
|
|
921
|
+
return codec(date$1(params), core._date(KrustyDate, params), {
|
|
922
|
+
encode: (date2) => `${date2.getFullYear()}-${String(date2.getMonth() + 1).padStart(2, "0")}-${String(date2.getDate()).padStart(2, "0")}`,
|
|
923
|
+
decode: (isoString2) => {
|
|
924
|
+
const [y, m, d] = isoString2.split("-");
|
|
925
|
+
return new Date(Number(y), Number(m) - 1, Number(d));
|
|
926
|
+
}
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
function datetime(params) {
|
|
930
|
+
return codec(datetime$1(params), core._date(KrustyDate, params), {
|
|
931
|
+
encode: (date2) => date2.toISOString(),
|
|
932
|
+
decode: (isoString2) => new Date(isoString2)
|
|
933
|
+
});
|
|
877
934
|
}
|
|
878
935
|
const KrustyArray = /* @__PURE__ */ core.$constructor(
|
|
879
936
|
"KrustyArray",
|
|
@@ -1458,10 +1515,12 @@ class SchemaClass {
|
|
|
1458
1515
|
object(shape, params) {
|
|
1459
1516
|
return object(shape, params);
|
|
1460
1517
|
}
|
|
1461
|
-
// TODO: make this a codec?
|
|
1462
1518
|
date(params) {
|
|
1463
1519
|
return date(params);
|
|
1464
1520
|
}
|
|
1521
|
+
datetime(params) {
|
|
1522
|
+
return datetime(params);
|
|
1523
|
+
}
|
|
1465
1524
|
any() {
|
|
1466
1525
|
return any();
|
|
1467
1526
|
}
|
|
@@ -1562,4 +1621,4 @@ class SchemaClass {
|
|
|
1562
1621
|
*/
|
|
1563
1622
|
}
|
|
1564
1623
|
|
|
1565
|
-
export { KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
|
1624
|
+
export { KrustyAny, KrustyArray, KrustyBase64, KrustyBase64URL, KrustyBigInt, KrustyBigIntFormat, KrustyBoolean, KrustyCIDRv4, KrustyCIDRv6, KrustyCUID, KrustyCUID2, KrustyCatch, KrustyCodec, KrustyCustom, KrustyCustomStringFormat, KrustyDate, KrustyDefault, KrustyDiscriminatedUnion, KrustyE164, KrustyEmail, KrustyEmoji, KrustyEnum, KrustyFile, KrustyFunction, KrustyGUID, KrustyGate, KrustyIPv4, KrustyIPv6, KrustyIntersection, KrustyJWT, KrustyKSUID, KrustyLazy, KrustyLiteral, KrustyMap, KrustyNaN, KrustyNanoID, KrustyNever, KrustyNonOptional, KrustyNull, KrustyNullable, KrustyNumber, KrustyNumberFormat, KrustyObject, KrustyOptional, KrustyPipe, KrustyPrefault, KrustyPromise, KrustyReadonly, KrustyRecord, KrustySet, KrustyString, KrustyStringFormat, KrustySuccess, KrustySymbol, KrustyTemplateLiteral, KrustyTransform, KrustyTuple, KrustyType, KrustyULID, KrustyURL, KrustyUUID, KrustyUndefined, KrustyUnion, KrustyUnknown, KrustyVoid, KrustyXID, SchemaClass, ZodError, ZodRealError, _KrustyString, _default, _function, any, array, base64, base64url, bigint, boolean, _catch as catch, check, cidrv4, cidrv6, codec, cuid, cuid2, custom, date, datetime, decode, decodeAsync, discriminatedUnion, e164, email, emoji, encode, encodeAsync, _enum as enum, file, float32, float64, _function as function, gate, gatingContext, guid, hash, hex, hostname, httpUrl, _instanceof as instanceof, int, int32, int64, intersection, ipv4, ipv6, isGateIssue, isGateIssueRaw, json, jwt, keyof, ksuid, lazy, literal, looseObject, map, nan, nanoid, nativeEnum, never, nonoptional, _null as null, nullable, nullish, number, object, optional, parse, parseAsync, partialRecord, pipe, prefault, promise, readonly, record, refine, safeDecode, safeDecodeAsync, safeEncode, safeEncodeAsync, safeParse, safeParseAsync, set, strictObject, string, stringFormat, stringbool, success, superRefine, symbol, templateLiteral, transform, tuple, uint32, uint64, ulid, _undefined as undefined, union, unknown, url, uuid, uuidv4, uuidv6, uuidv7, _void as void, xid };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/zod",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -23,17 +23,17 @@
|
|
|
23
23
|
"dist"
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@temporary-name/
|
|
27
|
-
"@temporary-name/server": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8"
|
|
26
|
+
"@temporary-name/server": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1"
|
|
28
27
|
},
|
|
29
28
|
"dependencies": {
|
|
30
29
|
"zod": "^4.1.11",
|
|
31
|
-
"@temporary-name/shared": "1.9.3-alpha.
|
|
30
|
+
"@temporary-name/shared": "1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {},
|
|
34
33
|
"scripts": {
|
|
35
34
|
"build": "unbuild",
|
|
36
35
|
"build:watch": "pnpm run build --watch",
|
|
36
|
+
"clean": "tsc -b --clean",
|
|
37
37
|
"type:check": "tsc -b"
|
|
38
38
|
}
|
|
39
39
|
}
|