gitea push
This commit is contained in:
+1
@@ -3,6 +3,7 @@ export * from "./parse.cjs";
|
||||
export * from "./schemas.cjs";
|
||||
export * from "./checks.cjs";
|
||||
export type { infer, output, input } from "../core/index.cjs";
|
||||
export type { JSONType } from "../core/util.cjs";
|
||||
export { globalRegistry, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, TimePrecision, util, NEVER, } from "../core/index.cjs";
|
||||
export { toJSONSchema } from "../core/json-schema-processors.cjs";
|
||||
export * as locales from "../locales/index.cjs";
|
||||
|
||||
+1
@@ -3,6 +3,7 @@ export * from "./parse.js";
|
||||
export * from "./schemas.js";
|
||||
export * from "./checks.js";
|
||||
export type { infer, output, input } from "../core/index.js";
|
||||
export type { JSONType } from "../core/util.js";
|
||||
export { globalRegistry, registry, config, $output, $input, $brand, clone, regexes, treeifyError, prettifyError, formatError, flattenError, TimePrecision, util, NEVER, } from "../core/index.js";
|
||||
export { toJSONSchema } from "../core/json-schema-processors.js";
|
||||
export * as locales from "../locales/index.js";
|
||||
|
||||
+2
-1
@@ -2,5 +2,6 @@
|
||||
"type": "module",
|
||||
"main": "./index.cjs",
|
||||
"module": "./index.js",
|
||||
"types": "./index.d.cts"
|
||||
"types": "./index.d.cts",
|
||||
"sideEffects": false
|
||||
}
|
||||
|
||||
+41
-4
@@ -112,6 +112,7 @@ exports.catch = _catch;
|
||||
exports.nan = nan;
|
||||
exports.pipe = pipe;
|
||||
exports.codec = codec;
|
||||
exports.invertCodec = invertCodec;
|
||||
exports.readonly = readonly;
|
||||
exports.templateLiteral = templateLiteral;
|
||||
exports.lazy = _lazy;
|
||||
@@ -144,7 +145,11 @@ exports.ZodMiniType = core.$constructor("ZodMiniType", (inst, def) => {
|
||||
...def,
|
||||
checks: [
|
||||
...(def.checks ?? []),
|
||||
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
||||
...checks.map((ch) => typeof ch === "function"
|
||||
? {
|
||||
_zod: { check: ch, def: { check: "custom" }, onattach: [] },
|
||||
}
|
||||
: ch),
|
||||
],
|
||||
}, { parent: true });
|
||||
};
|
||||
@@ -218,7 +223,7 @@ function url(params) {
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function httpUrl(params) {
|
||||
return core._url(exports.ZodMiniURL, {
|
||||
protocol: /^https?$/,
|
||||
protocol: core.regexes.httpProtocol,
|
||||
hostname: core.regexes.domain,
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
@@ -239,10 +244,22 @@ exports.ZodMiniNanoID = core.$constructor("ZodMiniNanoID", (inst, def) => {
|
||||
function nanoid(params) {
|
||||
return core._nanoid(exports.ZodMiniNanoID, params);
|
||||
}
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
exports.ZodMiniCUID = core.$constructor("ZodMiniCUID", (inst, def) => {
|
||||
core.$ZodCUID.init(inst, def);
|
||||
exports.ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
/**
|
||||
* Validates a CUID v1 string.
|
||||
*
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function cuid(params) {
|
||||
return core._cuid(exports.ZodMiniCUID, params);
|
||||
@@ -668,6 +685,15 @@ exports.ZodMiniRecord = core.$constructor("ZodMiniRecord", (inst, def) => {
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function record(keyType, valueType, params) {
|
||||
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
||||
if (!valueType || !valueType._zod) {
|
||||
return new exports.ZodMiniRecord({
|
||||
type: "record",
|
||||
keyType: string(),
|
||||
valueType: keyType,
|
||||
...util.normalizeParams(valueType),
|
||||
});
|
||||
}
|
||||
return new exports.ZodMiniRecord({
|
||||
type: "record",
|
||||
keyType,
|
||||
@@ -915,6 +941,17 @@ function codec(in_, out, params) {
|
||||
reverseTransform: params.encode,
|
||||
});
|
||||
}
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function invertCodec(codec) {
|
||||
const def = codec._zod.def;
|
||||
return new exports.ZodMiniCodec({
|
||||
type: "pipe",
|
||||
in: def.out,
|
||||
out: def.in,
|
||||
transform: def.reverseTransform,
|
||||
reverseTransform: def.transform,
|
||||
});
|
||||
}
|
||||
exports.ZodMiniReadonly = core.$constructor("ZodMiniReadonly", (inst, def) => {
|
||||
core.$ZodReadonly.init(inst, def);
|
||||
exports.ZodMiniType.init(inst, def);
|
||||
@@ -990,8 +1027,8 @@ function refine(fn, _params = {}) {
|
||||
}
|
||||
// superRefine
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
function superRefine(fn) {
|
||||
return core._superRefine(fn);
|
||||
function superRefine(fn, params) {
|
||||
return core._superRefine(fn, params);
|
||||
}
|
||||
// Re-export describe and meta from core
|
||||
exports.describe = core.describe;
|
||||
|
||||
+28
-10
@@ -58,9 +58,26 @@ export interface ZodMiniNanoID extends _ZodMiniString<core.$ZodNanoIDInternals>
|
||||
}
|
||||
export declare const ZodMiniNanoID: core.$constructor<ZodMiniNanoID>;
|
||||
export declare function nanoid(params?: string | core.$ZodNanoIDParams): ZodMiniNanoID;
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export interface ZodMiniCUID extends _ZodMiniString<core.$ZodCUIDInternals> {
|
||||
}
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export declare const ZodMiniCUID: core.$constructor<ZodMiniCUID>;
|
||||
/**
|
||||
* Validates a CUID v1 string.
|
||||
*
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export declare function cuid(params?: string | core.$ZodCUIDParams): ZodMiniCUID;
|
||||
export interface ZodMiniCUID2 extends _ZodMiniString<core.$ZodCUID2Internals> {
|
||||
}
|
||||
@@ -198,23 +215,23 @@ out Shape extends core.$ZodShape = core.$ZodShape, out Config extends core.$ZodO
|
||||
shape: Shape;
|
||||
}
|
||||
export declare const ZodMiniObject: core.$constructor<ZodMiniObject>;
|
||||
export declare function object<T extends core.$ZodLooseShape = Record<never, SomeType>>(shape?: T, params?: string | core.$ZodObjectParams): ZodMiniObject<T, core.$strip>;
|
||||
export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<T, core.$strict>;
|
||||
export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<T, core.$loose>;
|
||||
export declare function extend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: U): ZodMiniObject<util.Extend<T["shape"], U>, T["_zod"]["config"]>;
|
||||
export declare function object<T extends core.$ZodLooseShape = Record<never, SomeType>>(shape?: T, params?: string | core.$ZodObjectParams): ZodMiniObject<util.Writeable<T>, core.$strip>;
|
||||
export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<util.Writeable<T>, core.$strict>;
|
||||
export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<util.Writeable<T>, core.$loose>;
|
||||
export declare function extend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: U): ZodMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_zod"]["config"]>;
|
||||
export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
||||
[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];
|
||||
};
|
||||
export declare function safeExtend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: SafeExtendShape<T["shape"], U>): ZodMiniObject<util.Extend<T["shape"], U>, T["_zod"]["config"]>;
|
||||
export declare function safeExtend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: SafeExtendShape<T["shape"], U>): ZodMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_zod"]["config"]>;
|
||||
/** @deprecated Identical to `z.extend(A, B)` */
|
||||
export declare function merge<T extends ZodMiniObject, U extends ZodMiniObject>(a: T, b: U): ZodMiniObject<util.Extend<T["shape"], U["shape"]>, T["_zod"]["config"]>;
|
||||
export declare function pick<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<util.Flatten<Pick<T["shape"], keyof T["shape"] & keyof M>>, T["_zod"]["config"]>;
|
||||
export declare function omit<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<util.Flatten<Omit<T["shape"], keyof M>>, T["_zod"]["config"]>;
|
||||
export declare function partial<T extends ZodMiniObject>(schema: T): ZodMiniObject<{
|
||||
[k in keyof T["shape"]]: ZodMiniOptional<T["shape"][k]>;
|
||||
-readonly [k in keyof T["shape"]]: ZodMiniOptional<T["shape"][k]>;
|
||||
}, T["_zod"]["config"]>;
|
||||
export declare function partial<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<{
|
||||
[k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional<T["shape"][k]> : T["shape"][k];
|
||||
-readonly [k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional<T["shape"][k]> : T["shape"][k];
|
||||
}, T["_zod"]["config"]>;
|
||||
export type RequiredInterfaceShape<Shape extends core.$ZodLooseShape, Keys extends PropertyKey = keyof Shape> = util.Identity<{
|
||||
[k in keyof Shape as k extends Keys ? k : never]: ZodMiniNonOptional<Shape[k]>;
|
||||
@@ -222,7 +239,7 @@ export type RequiredInterfaceShape<Shape extends core.$ZodLooseShape, Keys exten
|
||||
[k in keyof Shape as k extends Keys ? never : k]: Shape[k];
|
||||
}>;
|
||||
export declare function required<T extends ZodMiniObject>(schema: T): ZodMiniObject<{
|
||||
[k in keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
||||
-readonly [k in keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
||||
}, T["_zod"]["config"]>;
|
||||
export declare function required<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<util.Extend<T["shape"], {
|
||||
[k in keyof M & keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
||||
@@ -243,7 +260,7 @@ export interface ZodMiniDiscriminatedUnion<Options extends readonly SomeType[] =
|
||||
_zod: core.$ZodDiscriminatedUnionInternals<Options, Disc>;
|
||||
}
|
||||
export declare const ZodMiniDiscriminatedUnion: core.$constructor<ZodMiniDiscriminatedUnion>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodMiniDiscriminatedUnion<Types, Disc>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable<Disc>, ...core.$ZodTypeDiscriminable<Disc>[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodMiniDiscriminatedUnion<Types, Disc>;
|
||||
export interface ZodMiniIntersection<A extends SomeType = core.$ZodType, B extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodIntersectionInternals<A, B>> {
|
||||
}
|
||||
export declare const ZodMiniIntersection: core.$constructor<ZodMiniIntersection>;
|
||||
@@ -347,6 +364,7 @@ export declare function codec<const A extends SomeType, B extends core.SomeType
|
||||
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
||||
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
||||
}): ZodMiniCodec<A, B>;
|
||||
export declare function invertCodec<A extends SomeType, B extends SomeType>(codec: ZodMiniCodec<A, B>): ZodMiniCodec<B, A>;
|
||||
export interface ZodMiniReadonly<T extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodReadonlyInternals<T>> {
|
||||
}
|
||||
export declare const ZodMiniReadonly: core.$constructor<ZodMiniReadonly>;
|
||||
@@ -370,7 +388,7 @@ export declare const ZodMiniCustom: core.$constructor<ZodMiniCustom>;
|
||||
export declare function check<O = unknown>(fn: core.CheckFn<O>, params?: string | core.$ZodCustomParams): core.$ZodCheck<O>;
|
||||
export declare function custom<O = unknown, I = O>(fn?: (data: O) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodMiniCustom<O, I>;
|
||||
export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>, params?: core.$ZodSuperRefineParams): core.$ZodCheck<T>;
|
||||
export declare const describe: typeof core.describe;
|
||||
export declare const meta: typeof core.meta;
|
||||
declare abstract class Class {
|
||||
|
||||
+28
-10
@@ -58,9 +58,26 @@ export interface ZodMiniNanoID extends _ZodMiniString<core.$ZodNanoIDInternals>
|
||||
}
|
||||
export declare const ZodMiniNanoID: core.$constructor<ZodMiniNanoID>;
|
||||
export declare function nanoid(params?: string | core.$ZodNanoIDParams): ZodMiniNanoID;
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export interface ZodMiniCUID extends _ZodMiniString<core.$ZodCUIDInternals> {
|
||||
}
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export declare const ZodMiniCUID: core.$constructor<ZodMiniCUID>;
|
||||
/**
|
||||
* Validates a CUID v1 string.
|
||||
*
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export declare function cuid(params?: string | core.$ZodCUIDParams): ZodMiniCUID;
|
||||
export interface ZodMiniCUID2 extends _ZodMiniString<core.$ZodCUID2Internals> {
|
||||
}
|
||||
@@ -198,23 +215,23 @@ out Shape extends core.$ZodShape = core.$ZodShape, out Config extends core.$ZodO
|
||||
shape: Shape;
|
||||
}
|
||||
export declare const ZodMiniObject: core.$constructor<ZodMiniObject>;
|
||||
export declare function object<T extends core.$ZodLooseShape = Record<never, SomeType>>(shape?: T, params?: string | core.$ZodObjectParams): ZodMiniObject<T, core.$strip>;
|
||||
export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<T, core.$strict>;
|
||||
export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<T, core.$loose>;
|
||||
export declare function extend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: U): ZodMiniObject<util.Extend<T["shape"], U>, T["_zod"]["config"]>;
|
||||
export declare function object<T extends core.$ZodLooseShape = Record<never, SomeType>>(shape?: T, params?: string | core.$ZodObjectParams): ZodMiniObject<util.Writeable<T>, core.$strip>;
|
||||
export declare function strictObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<util.Writeable<T>, core.$strict>;
|
||||
export declare function looseObject<T extends core.$ZodLooseShape>(shape: T, params?: string | core.$ZodObjectParams): ZodMiniObject<util.Writeable<T>, core.$loose>;
|
||||
export declare function extend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: U): ZodMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_zod"]["config"]>;
|
||||
export type SafeExtendShape<Base extends core.$ZodShape, Ext extends core.$ZodLooseShape> = {
|
||||
[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];
|
||||
};
|
||||
export declare function safeExtend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: SafeExtendShape<T["shape"], U>): ZodMiniObject<util.Extend<T["shape"], U>, T["_zod"]["config"]>;
|
||||
export declare function safeExtend<T extends ZodMiniObject, U extends core.$ZodLooseShape>(schema: T, shape: SafeExtendShape<T["shape"], U>): ZodMiniObject<util.Extend<T["shape"], util.Writeable<U>>, T["_zod"]["config"]>;
|
||||
/** @deprecated Identical to `z.extend(A, B)` */
|
||||
export declare function merge<T extends ZodMiniObject, U extends ZodMiniObject>(a: T, b: U): ZodMiniObject<util.Extend<T["shape"], U["shape"]>, T["_zod"]["config"]>;
|
||||
export declare function pick<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<util.Flatten<Pick<T["shape"], keyof T["shape"] & keyof M>>, T["_zod"]["config"]>;
|
||||
export declare function omit<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<util.Flatten<Omit<T["shape"], keyof M>>, T["_zod"]["config"]>;
|
||||
export declare function partial<T extends ZodMiniObject>(schema: T): ZodMiniObject<{
|
||||
[k in keyof T["shape"]]: ZodMiniOptional<T["shape"][k]>;
|
||||
-readonly [k in keyof T["shape"]]: ZodMiniOptional<T["shape"][k]>;
|
||||
}, T["_zod"]["config"]>;
|
||||
export declare function partial<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<{
|
||||
[k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional<T["shape"][k]> : T["shape"][k];
|
||||
-readonly [k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional<T["shape"][k]> : T["shape"][k];
|
||||
}, T["_zod"]["config"]>;
|
||||
export type RequiredInterfaceShape<Shape extends core.$ZodLooseShape, Keys extends PropertyKey = keyof Shape> = util.Identity<{
|
||||
[k in keyof Shape as k extends Keys ? k : never]: ZodMiniNonOptional<Shape[k]>;
|
||||
@@ -222,7 +239,7 @@ export type RequiredInterfaceShape<Shape extends core.$ZodLooseShape, Keys exten
|
||||
[k in keyof Shape as k extends Keys ? never : k]: Shape[k];
|
||||
}>;
|
||||
export declare function required<T extends ZodMiniObject>(schema: T): ZodMiniObject<{
|
||||
[k in keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
||||
-readonly [k in keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
||||
}, T["_zod"]["config"]>;
|
||||
export declare function required<T extends ZodMiniObject, M extends util.Mask<keyof T["shape"]>>(schema: T, mask: M & Record<Exclude<keyof M, keyof T["shape"]>, never>): ZodMiniObject<util.Extend<T["shape"], {
|
||||
[k in keyof M & keyof T["shape"]]: ZodMiniNonOptional<T["shape"][k]>;
|
||||
@@ -243,7 +260,7 @@ export interface ZodMiniDiscriminatedUnion<Options extends readonly SomeType[] =
|
||||
_zod: core.$ZodDiscriminatedUnionInternals<Options, Disc>;
|
||||
}
|
||||
export declare const ZodMiniDiscriminatedUnion: core.$constructor<ZodMiniDiscriminatedUnion>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodMiniDiscriminatedUnion<Types, Disc>;
|
||||
export declare function discriminatedUnion<Types extends readonly [core.$ZodTypeDiscriminable<Disc>, ...core.$ZodTypeDiscriminable<Disc>[]], Disc extends string>(discriminator: Disc, options: Types, params?: string | core.$ZodDiscriminatedUnionParams): ZodMiniDiscriminatedUnion<Types, Disc>;
|
||||
export interface ZodMiniIntersection<A extends SomeType = core.$ZodType, B extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodIntersectionInternals<A, B>> {
|
||||
}
|
||||
export declare const ZodMiniIntersection: core.$constructor<ZodMiniIntersection>;
|
||||
@@ -347,6 +364,7 @@ export declare function codec<const A extends SomeType, B extends core.SomeType
|
||||
decode: (value: core.output<A>, payload: core.ParsePayload<core.output<A>>) => core.util.MaybeAsync<core.input<B>>;
|
||||
encode: (value: core.input<B>, payload: core.ParsePayload<core.input<B>>) => core.util.MaybeAsync<core.output<A>>;
|
||||
}): ZodMiniCodec<A, B>;
|
||||
export declare function invertCodec<A extends SomeType, B extends SomeType>(codec: ZodMiniCodec<A, B>): ZodMiniCodec<B, A>;
|
||||
export interface ZodMiniReadonly<T extends SomeType = core.$ZodType> extends _ZodMiniType<core.$ZodReadonlyInternals<T>> {
|
||||
}
|
||||
export declare const ZodMiniReadonly: core.$constructor<ZodMiniReadonly>;
|
||||
@@ -370,7 +388,7 @@ export declare const ZodMiniCustom: core.$constructor<ZodMiniCustom>;
|
||||
export declare function check<O = unknown>(fn: core.CheckFn<O>, params?: string | core.$ZodCustomParams): core.$ZodCheck<O>;
|
||||
export declare function custom<O = unknown, I = O>(fn?: (data: O) => unknown, _params?: string | core.$ZodCustomParams | undefined): ZodMiniCustom<O, I>;
|
||||
export declare function refine<T>(fn: (arg: NoInfer<T>) => util.MaybeAsync<unknown>, _params?: string | core.$ZodCustomParams): core.$ZodCheck<T>;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>): core.$ZodCheck<T>;
|
||||
export declare function superRefine<T>(fn: (arg: T, payload: core.$RefinementCtx<T>) => void | Promise<void>, params?: core.$ZodSuperRefineParams): core.$ZodCheck<T>;
|
||||
export declare const describe: typeof core.describe;
|
||||
export declare const meta: typeof core.meta;
|
||||
declare abstract class Class {
|
||||
|
||||
+40
-4
@@ -16,7 +16,11 @@ export const ZodMiniType = /*@__PURE__*/ core.$constructor("ZodMiniType", (inst,
|
||||
...def,
|
||||
checks: [
|
||||
...(def.checks ?? []),
|
||||
...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch),
|
||||
...checks.map((ch) => typeof ch === "function"
|
||||
? {
|
||||
_zod: { check: ch, def: { check: "custom" }, onattach: [] },
|
||||
}
|
||||
: ch),
|
||||
],
|
||||
}, { parent: true });
|
||||
};
|
||||
@@ -90,7 +94,7 @@ export function url(params) {
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
export function httpUrl(params) {
|
||||
return core._url(ZodMiniURL, {
|
||||
protocol: /^https?$/,
|
||||
protocol: core.regexes.httpProtocol,
|
||||
hostname: core.regexes.domain,
|
||||
...util.normalizeParams(params),
|
||||
});
|
||||
@@ -111,10 +115,22 @@ export const ZodMiniNanoID = /*@__PURE__*/ core.$constructor("ZodMiniNanoID", (i
|
||||
export function nanoid(params) {
|
||||
return core._nanoid(ZodMiniNanoID, params);
|
||||
}
|
||||
/**
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
export const ZodMiniCUID = /*@__PURE__*/ core.$constructor("ZodMiniCUID", (inst, def) => {
|
||||
core.$ZodCUID.init(inst, def);
|
||||
ZodMiniStringFormat.init(inst, def);
|
||||
});
|
||||
/**
|
||||
* Validates a CUID v1 string.
|
||||
*
|
||||
* @deprecated CUID v1 is deprecated by its authors due to information leakage
|
||||
* (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead.
|
||||
* See https://github.com/paralleldrive/cuid.
|
||||
*/
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
export function cuid(params) {
|
||||
return core._cuid(ZodMiniCUID, params);
|
||||
@@ -543,6 +559,15 @@ export const ZodMiniRecord = /*@__PURE__*/ core.$constructor("ZodMiniRecord", (i
|
||||
});
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
export function record(keyType, valueType, params) {
|
||||
// v3-compat: z.record(valueType, params?) — defaults keyType to z.string()
|
||||
if (!valueType || !valueType._zod) {
|
||||
return new ZodMiniRecord({
|
||||
type: "record",
|
||||
keyType: string(),
|
||||
valueType: keyType,
|
||||
...util.normalizeParams(valueType),
|
||||
});
|
||||
}
|
||||
return new ZodMiniRecord({
|
||||
type: "record",
|
||||
keyType,
|
||||
@@ -792,6 +817,17 @@ export function codec(in_, out, params) {
|
||||
reverseTransform: params.encode,
|
||||
});
|
||||
}
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
export function invertCodec(codec) {
|
||||
const def = codec._zod.def;
|
||||
return new ZodMiniCodec({
|
||||
type: "pipe",
|
||||
in: def.out,
|
||||
out: def.in,
|
||||
transform: def.reverseTransform,
|
||||
reverseTransform: def.transform,
|
||||
});
|
||||
}
|
||||
export const ZodMiniReadonly = /*@__PURE__*/ core.$constructor("ZodMiniReadonly", (inst, def) => {
|
||||
core.$ZodReadonly.init(inst, def);
|
||||
ZodMiniType.init(inst, def);
|
||||
@@ -868,8 +904,8 @@ export function refine(fn, _params = {}) {
|
||||
}
|
||||
// superRefine
|
||||
// @__NO_SIDE_EFFECTS__
|
||||
export function superRefine(fn) {
|
||||
return core._superRefine(fn);
|
||||
export function superRefine(fn, params) {
|
||||
return core._superRefine(fn, params);
|
||||
}
|
||||
// Re-export describe and meta from core
|
||||
export const describe = core.describe;
|
||||
|
||||
Reference in New Issue
Block a user