zod 4.0.0-beta.20250409T222615 → 4.0.0-beta.20250410T041446
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/commonjs/errors.d.ts +2 -1
- package/dist/commonjs/errors.js +2 -1
- package/dist/commonjs/schemas.d.ts +16 -4
- package/dist/commonjs/schemas.js +23 -4
- package/dist/esm/errors.d.ts +2 -1
- package/dist/esm/errors.js +2 -1
- package/dist/esm/schemas.d.ts +16 -4
- package/dist/esm/schemas.js +19 -2
- package/package.json +2 -2
- package/src/errors.ts +2 -4
- package/src/schemas.ts +47 -11
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as core from "@zod/core";
|
|
2
|
+
import { $ZodError } from "@zod/core";
|
|
2
3
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
3
4
|
export type ZodIssue = core.$ZodIssue;
|
|
4
|
-
export declare class ZodError<T = unknown> extends
|
|
5
|
+
export declare class ZodError<T = unknown> extends $ZodError<T> {
|
|
5
6
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
6
7
|
format(): core.$ZodFormattedError<T>;
|
|
7
8
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
package/dist/commonjs/errors.js
CHANGED
|
@@ -35,7 +35,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ZodError = void 0;
|
|
37
37
|
const core = __importStar(require("@zod/core"));
|
|
38
|
-
|
|
38
|
+
const core_1 = require("@zod/core");
|
|
39
|
+
class ZodError extends core_1.$ZodError {
|
|
39
40
|
format(mapper) {
|
|
40
41
|
return core.formatError(this, mapper);
|
|
41
42
|
}
|
|
@@ -32,7 +32,6 @@ export interface ZodType<out Output = unknown, out Input = unknown> extends core
|
|
|
32
32
|
default(def: () => util.NoUndefined<core.output<this>>, params?: core.$ZodDefaultParams): ZodDefault<this>;
|
|
33
33
|
array(): ZodArray<this>;
|
|
34
34
|
or<T extends core.$ZodType>(option: T): ZodUnion<[this, T]>;
|
|
35
|
-
and<T extends core.$ZodType>(incoming: T): ZodIntersection<this, T>;
|
|
36
35
|
transform<NewOut>(transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
|
37
36
|
catch(def: core.output<this>): ZodCatch<this>;
|
|
38
37
|
catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
|
|
@@ -92,6 +91,10 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
92
91
|
ipv4(params?: string | core.$ZodCheckIPv4Params): this;
|
|
93
92
|
/** @deprecated Use `z.ipv6()` instead. */
|
|
94
93
|
ipv6(params?: string | core.$ZodCheckIPv6Params): this;
|
|
94
|
+
/** @deprecated Use `z.cidrv4()` instead. */
|
|
95
|
+
cidrv4(params?: string | core.$ZodCheckCIDRv4Params): this;
|
|
96
|
+
/** @deprecated Use `z.cidrv6()` instead. */
|
|
97
|
+
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
95
98
|
/** @deprecated Use `z.e164()` instead. */
|
|
96
99
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
97
100
|
/** @deprecated Use `z.iso.datetime()` instead. */
|
|
@@ -196,6 +199,16 @@ export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
|
|
|
196
199
|
}
|
|
197
200
|
export declare const ZodIPv6: core.$constructor<ZodIPv6>;
|
|
198
201
|
export declare function ipv6(params?: string | core.$ZodIPv6Params): ZodIPv6;
|
|
202
|
+
export interface ZodCIDRv4 extends ZodStringFormat<"cidrv4"> {
|
|
203
|
+
_zod: core.$ZodCIDRv4Internals;
|
|
204
|
+
}
|
|
205
|
+
export declare const ZodCIDRv4: core.$constructor<ZodCIDRv4>;
|
|
206
|
+
export declare function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodCIDRv4;
|
|
207
|
+
export interface ZodCIDRv6 extends ZodStringFormat<"cidrv6"> {
|
|
208
|
+
_zod: core.$ZodCIDRv6Internals;
|
|
209
|
+
}
|
|
210
|
+
export declare const ZodCIDRv6: core.$constructor<ZodCIDRv6>;
|
|
211
|
+
export declare function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodCIDRv6;
|
|
199
212
|
export interface ZodBase64 extends ZodStringFormat<"base64"> {
|
|
200
213
|
_zod: core.$ZodBase64Internals;
|
|
201
214
|
}
|
|
@@ -430,7 +443,6 @@ declare function _interface<T extends core.$ZodLooseShape>(shape: T, params?: co
|
|
|
430
443
|
export { _interface as interface };
|
|
431
444
|
export declare function strictInterface<T extends core.$ZodLooseShape>(shape: T, params?: core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, {}>>;
|
|
432
445
|
export declare function looseInterface<T extends core.$ZodLooseShape>(shape: T, params?: core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, Record<string, unknown>>>;
|
|
433
|
-
type MergeObjects<A extends ZodObject, B extends ZodObject> = ZodObject<util.ExtendShape<A["_zod"]["shape"], B["_zod"]["shape"]>, A["_zod"]["extra"]>;
|
|
434
446
|
export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Extra extends Record<string, unknown> = Record<string, unknown>> extends ZodType {
|
|
435
447
|
_zod: core.$ZodObjectInternals<Shape, Extra>;
|
|
436
448
|
/** @deprecated In Zod 4, you can pass `ZodObject` instances directly into `.extend()`. */
|
|
@@ -445,8 +457,8 @@ export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Ex
|
|
|
445
457
|
strict(): ZodObject<Shape, {}>;
|
|
446
458
|
/** @deprecated This is the default behavior. This method call is likely unnecessary. */
|
|
447
459
|
strip(): ZodObject<Shape, {}>;
|
|
448
|
-
extend<U extends ZodObject>(shape: U):
|
|
449
|
-
extend<U extends core.$ZodShape>(shape: U):
|
|
460
|
+
extend<U extends ZodObject>(shape: U): ZodObject<util.ExtendShape<Shape, U["_zod"]["shape"]>, Extra>;
|
|
461
|
+
extend<U extends core.$ZodShape>(shape: U): ZodObject<util.ExtendShape<Shape, U>, Extra>;
|
|
450
462
|
/** @deprecated Use `A.extend(B)` */
|
|
451
463
|
merge<U extends ZodObject<any, any>>(other: U): ZodObject<util.Flatten<util.Overwrite<Shape, U["_zod"]["def"]["shape"]>>, Extra>;
|
|
452
464
|
pick<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Extra>;
|
package/dist/commonjs/schemas.js
CHANGED
|
@@ -33,8 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.
|
|
37
|
-
exports.stringbool = exports.ZodCustom = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodDefault = exports.ZodNullable = void 0;
|
|
36
|
+
exports.ZodFile = exports.ZodLiteral = exports.ZodEnum = exports.ZodSet = exports.ZodMap = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodDiscriminatedUnion = exports.ZodUnion = exports.ZodObject = exports.ZodInterface = exports.ZodObjectLike = exports.ZodArray = exports.ZodDate = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodSymbol = exports.ZodBigIntFormat = exports.ZodBigInt = exports.ZodBoolean = exports.ZodNumberFormat = exports.ZodNumber = exports.ZodJWT = exports.ZodE164 = exports.ZodBase64 = exports.ZodCIDRv6 = exports.ZodCIDRv4 = exports.ZodIPv6 = exports.ZodIPv4 = exports.ZodKSUID = exports.ZodXID = exports.ZodULID = exports.ZodCUID2 = exports.ZodCUID = exports.ZodNanoID = exports.ZodEmoji = exports.ZodURL = exports.ZodUUID = exports.ZodGUID = exports.ZodEmail = exports.ZodStringFormat = exports.ZodString = exports.ZodType = exports.coerce = exports.iso = void 0;
|
|
37
|
+
exports.stringbool = exports.ZodCustom = exports.ZodPromise = exports.ZodLazy = exports.ZodTemplateLiteral = exports.ZodReadonly = exports.ZodPipe = exports.ZodNaN = exports.ZodCatch = exports.ZodSuccess = exports.ZodNonOptional = exports.ZodDefault = exports.ZodNullable = exports.ZodOptional = exports.ZodTransform = void 0;
|
|
38
38
|
exports.string = string;
|
|
39
39
|
exports.email = email;
|
|
40
40
|
exports.guid = guid;
|
|
@@ -52,6 +52,8 @@ exports.xid = xid;
|
|
|
52
52
|
exports.ksuid = ksuid;
|
|
53
53
|
exports.ipv4 = ipv4;
|
|
54
54
|
exports.ipv6 = ipv6;
|
|
55
|
+
exports.cidrv4 = cidrv4;
|
|
56
|
+
exports.cidrv6 = cidrv6;
|
|
55
57
|
exports.base64 = base64;
|
|
56
58
|
exports.e164 = e164;
|
|
57
59
|
exports.jwt = jwt;
|
|
@@ -163,7 +165,7 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
|
163
165
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
164
166
|
inst.array = () => array(inst);
|
|
165
167
|
inst.or = (arg) => union([inst, arg]);
|
|
166
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
168
|
+
// inst.and = (arg) => intersection(inst, arg);
|
|
167
169
|
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
168
170
|
inst.default = (def, params) => _default(inst, def, params);
|
|
169
171
|
// inst.coalesce = (def, params) => coalesce(inst, def, params);
|
|
@@ -229,6 +231,8 @@ exports.ZodString = core.$constructor("ZodString", (inst, def) => {
|
|
|
229
231
|
// };
|
|
230
232
|
inst.ipv4 = (params) => inst.check(core._ipv4(exports.ZodIPv4, params));
|
|
231
233
|
inst.ipv6 = (params) => inst.check(core._ipv6(exports.ZodIPv6, params));
|
|
234
|
+
inst.cidrv4 = (params) => inst.check(core._cidrv4(exports.ZodCIDRv4, params));
|
|
235
|
+
inst.cidrv6 = (params) => inst.check(core._cidrv6(exports.ZodCIDRv6, params));
|
|
232
236
|
inst.e164 = (params) => inst.check(core._e164(exports.ZodE164, params));
|
|
233
237
|
// iso
|
|
234
238
|
inst.datetime = (params) => inst.check(iso.datetime(params));
|
|
@@ -374,6 +378,20 @@ exports.ZodIPv6 = core.$constructor("ZodIPv6", (inst, def) => {
|
|
|
374
378
|
function ipv6(params) {
|
|
375
379
|
return core._ipv6(exports.ZodIPv6, params);
|
|
376
380
|
}
|
|
381
|
+
exports.ZodCIDRv4 = core.$constructor("ZodCIDRv4", (inst, def) => {
|
|
382
|
+
core.$ZodCIDRv4.init(inst, def);
|
|
383
|
+
exports.ZodType.init(inst, def);
|
|
384
|
+
});
|
|
385
|
+
function cidrv4(params) {
|
|
386
|
+
return core._cidrv4(exports.ZodCIDRv4, params);
|
|
387
|
+
}
|
|
388
|
+
exports.ZodCIDRv6 = core.$constructor("ZodCIDRv6", (inst, def) => {
|
|
389
|
+
core.$ZodCIDRv6.init(inst, def);
|
|
390
|
+
exports.ZodType.init(inst, def);
|
|
391
|
+
});
|
|
392
|
+
function cidrv6(params) {
|
|
393
|
+
return core._cidrv6(exports.ZodCIDRv6, params);
|
|
394
|
+
}
|
|
377
395
|
exports.ZodBase64 = core.$constructor("ZodBase64", (inst, def) => {
|
|
378
396
|
// ZodStringFormat.init(inst, def);
|
|
379
397
|
core.$ZodBase64.init(inst, def);
|
|
@@ -1154,7 +1172,8 @@ function _instanceof(cls, params = {
|
|
|
1154
1172
|
});
|
|
1155
1173
|
}
|
|
1156
1174
|
// stringbool
|
|
1157
|
-
exports.stringbool =
|
|
1175
|
+
exports.stringbool =
|
|
1176
|
+
/*@__PURE__*/ core._stringbool.bind(null, {
|
|
1158
1177
|
Pipe: exports.ZodPipe,
|
|
1159
1178
|
Boolean: exports.ZodBoolean,
|
|
1160
1179
|
Unknown: exports.ZodUnknown,
|
package/dist/esm/errors.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as core from "@zod/core";
|
|
2
|
+
import { $ZodError } from "@zod/core";
|
|
2
3
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
3
4
|
export type ZodIssue = core.$ZodIssue;
|
|
4
|
-
export declare class ZodError<T = unknown> extends
|
|
5
|
+
export declare class ZodError<T = unknown> extends $ZodError<T> {
|
|
5
6
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
6
7
|
format(): core.$ZodFormattedError<T>;
|
|
7
8
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
package/dist/esm/errors.js
CHANGED
package/dist/esm/schemas.d.ts
CHANGED
|
@@ -32,7 +32,6 @@ export interface ZodType<out Output = unknown, out Input = unknown> extends core
|
|
|
32
32
|
default(def: () => util.NoUndefined<core.output<this>>, params?: core.$ZodDefaultParams): ZodDefault<this>;
|
|
33
33
|
array(): ZodArray<this>;
|
|
34
34
|
or<T extends core.$ZodType>(option: T): ZodUnion<[this, T]>;
|
|
35
|
-
and<T extends core.$ZodType>(incoming: T): ZodIntersection<this, T>;
|
|
36
35
|
transform<NewOut>(transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
|
37
36
|
catch(def: core.output<this>): ZodCatch<this>;
|
|
38
37
|
catch(def: (ctx: core.$ZodCatchCtx) => core.output<this>): ZodCatch<this>;
|
|
@@ -92,6 +91,10 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
92
91
|
ipv4(params?: string | core.$ZodCheckIPv4Params): this;
|
|
93
92
|
/** @deprecated Use `z.ipv6()` instead. */
|
|
94
93
|
ipv6(params?: string | core.$ZodCheckIPv6Params): this;
|
|
94
|
+
/** @deprecated Use `z.cidrv4()` instead. */
|
|
95
|
+
cidrv4(params?: string | core.$ZodCheckCIDRv4Params): this;
|
|
96
|
+
/** @deprecated Use `z.cidrv6()` instead. */
|
|
97
|
+
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
95
98
|
/** @deprecated Use `z.e164()` instead. */
|
|
96
99
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
97
100
|
/** @deprecated Use `z.iso.datetime()` instead. */
|
|
@@ -196,6 +199,16 @@ export interface ZodIPv6 extends ZodStringFormat<"ipv6"> {
|
|
|
196
199
|
}
|
|
197
200
|
export declare const ZodIPv6: core.$constructor<ZodIPv6>;
|
|
198
201
|
export declare function ipv6(params?: string | core.$ZodIPv6Params): ZodIPv6;
|
|
202
|
+
export interface ZodCIDRv4 extends ZodStringFormat<"cidrv4"> {
|
|
203
|
+
_zod: core.$ZodCIDRv4Internals;
|
|
204
|
+
}
|
|
205
|
+
export declare const ZodCIDRv4: core.$constructor<ZodCIDRv4>;
|
|
206
|
+
export declare function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodCIDRv4;
|
|
207
|
+
export interface ZodCIDRv6 extends ZodStringFormat<"cidrv6"> {
|
|
208
|
+
_zod: core.$ZodCIDRv6Internals;
|
|
209
|
+
}
|
|
210
|
+
export declare const ZodCIDRv6: core.$constructor<ZodCIDRv6>;
|
|
211
|
+
export declare function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodCIDRv6;
|
|
199
212
|
export interface ZodBase64 extends ZodStringFormat<"base64"> {
|
|
200
213
|
_zod: core.$ZodBase64Internals;
|
|
201
214
|
}
|
|
@@ -430,7 +443,6 @@ declare function _interface<T extends core.$ZodLooseShape>(shape: T, params?: co
|
|
|
430
443
|
export { _interface as interface };
|
|
431
444
|
export declare function strictInterface<T extends core.$ZodLooseShape>(shape: T, params?: core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, {}>>;
|
|
432
445
|
export declare function looseInterface<T extends core.$ZodLooseShape>(shape: T, params?: core.$ZodInterfaceParams): ZodInterface<util.CleanInterfaceShape<T>, util.InitInterfaceParams<T, Record<string, unknown>>>;
|
|
433
|
-
type MergeObjects<A extends ZodObject, B extends ZodObject> = ZodObject<util.ExtendShape<A["_zod"]["shape"], B["_zod"]["shape"]>, A["_zod"]["extra"]>;
|
|
434
446
|
export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Extra extends Record<string, unknown> = Record<string, unknown>> extends ZodType {
|
|
435
447
|
_zod: core.$ZodObjectInternals<Shape, Extra>;
|
|
436
448
|
/** @deprecated In Zod 4, you can pass `ZodObject` instances directly into `.extend()`. */
|
|
@@ -445,8 +457,8 @@ export interface ZodObject<out Shape extends core.$ZodShape = core.$ZodShape, Ex
|
|
|
445
457
|
strict(): ZodObject<Shape, {}>;
|
|
446
458
|
/** @deprecated This is the default behavior. This method call is likely unnecessary. */
|
|
447
459
|
strip(): ZodObject<Shape, {}>;
|
|
448
|
-
extend<U extends ZodObject>(shape: U):
|
|
449
|
-
extend<U extends core.$ZodShape>(shape: U):
|
|
460
|
+
extend<U extends ZodObject>(shape: U): ZodObject<util.ExtendShape<Shape, U["_zod"]["shape"]>, Extra>;
|
|
461
|
+
extend<U extends core.$ZodShape>(shape: U): ZodObject<util.ExtendShape<Shape, U>, Extra>;
|
|
450
462
|
/** @deprecated Use `A.extend(B)` */
|
|
451
463
|
merge<U extends ZodObject<any, any>>(other: U): ZodObject<util.Flatten<util.Overwrite<Shape, U["_zod"]["def"]["shape"]>>, Extra>;
|
|
452
464
|
pick<M extends util.Exactly<util.Mask<string & keyof Shape>, M>>(mask: M): ZodObject<util.Flatten<Pick<Shape, Extract<keyof Shape, keyof M>>>, Extra>;
|
package/dist/esm/schemas.js
CHANGED
|
@@ -42,7 +42,7 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
42
42
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
43
43
|
inst.array = () => array(inst);
|
|
44
44
|
inst.or = (arg) => union([inst, arg]);
|
|
45
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
45
|
+
// inst.and = (arg) => intersection(inst, arg);
|
|
46
46
|
inst.transform = (tx) => pipe(inst, transform(tx));
|
|
47
47
|
inst.default = (def, params) => _default(inst, def, params);
|
|
48
48
|
// inst.coalesce = (def, params) => coalesce(inst, def, params);
|
|
@@ -108,6 +108,8 @@ export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def
|
|
|
108
108
|
// };
|
|
109
109
|
inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
|
|
110
110
|
inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
|
|
111
|
+
inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
|
|
112
|
+
inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));
|
|
111
113
|
inst.e164 = (params) => inst.check(core._e164(ZodE164, params));
|
|
112
114
|
// iso
|
|
113
115
|
inst.datetime = (params) => inst.check(iso.datetime(params));
|
|
@@ -253,6 +255,20 @@ export const ZodIPv6 = /*@__PURE__*/ core.$constructor("ZodIPv6", (inst, def) =>
|
|
|
253
255
|
export function ipv6(params) {
|
|
254
256
|
return core._ipv6(ZodIPv6, params);
|
|
255
257
|
}
|
|
258
|
+
export const ZodCIDRv4 = /*@__PURE__*/ core.$constructor("ZodCIDRv4", (inst, def) => {
|
|
259
|
+
core.$ZodCIDRv4.init(inst, def);
|
|
260
|
+
ZodType.init(inst, def);
|
|
261
|
+
});
|
|
262
|
+
export function cidrv4(params) {
|
|
263
|
+
return core._cidrv4(ZodCIDRv4, params);
|
|
264
|
+
}
|
|
265
|
+
export const ZodCIDRv6 = /*@__PURE__*/ core.$constructor("ZodCIDRv6", (inst, def) => {
|
|
266
|
+
core.$ZodCIDRv6.init(inst, def);
|
|
267
|
+
ZodType.init(inst, def);
|
|
268
|
+
});
|
|
269
|
+
export function cidrv6(params) {
|
|
270
|
+
return core._cidrv6(ZodCIDRv6, params);
|
|
271
|
+
}
|
|
256
272
|
export const ZodBase64 = /*@__PURE__*/ core.$constructor("ZodBase64", (inst, def) => {
|
|
257
273
|
// ZodStringFormat.init(inst, def);
|
|
258
274
|
core.$ZodBase64.init(inst, def);
|
|
@@ -1040,7 +1056,8 @@ function _instanceof(cls, params = {
|
|
|
1040
1056
|
}
|
|
1041
1057
|
export { _instanceof as instanceof };
|
|
1042
1058
|
// stringbool
|
|
1043
|
-
export const stringbool =
|
|
1059
|
+
export const stringbool =
|
|
1060
|
+
/*@__PURE__*/ core._stringbool.bind(null, {
|
|
1044
1061
|
Pipe: ZodPipe,
|
|
1045
1062
|
Boolean: ZodBoolean,
|
|
1046
1063
|
Unknown: ZodUnknown,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.20250410T041446",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Colin McDonnell <zod@colinhacks.com>",
|
|
6
6
|
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@zod/core": "0.1
|
|
73
|
+
"@zod/core": "0.2.1"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"clean": "rm -rf dist",
|
package/src/errors.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as core from "@zod/core";
|
|
2
|
+
import { $ZodError } from "@zod/core";
|
|
2
3
|
import type { AnyFunc } from "@zod/core/util";
|
|
3
4
|
|
|
4
5
|
/** @deprecated Use `z.core.$ZodIssue` from `@zod/core` instead, especially if you are building a library on top of Zod. */
|
|
5
6
|
export type ZodIssue = core.$ZodIssue;
|
|
6
7
|
|
|
7
|
-
export class ZodError<T = unknown> extends
|
|
8
|
+
export class ZodError<T = unknown> extends $ZodError<T> {
|
|
8
9
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
9
10
|
format(): core.$ZodFormattedError<T>;
|
|
10
11
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
@@ -12,7 +13,6 @@ export class ZodError<T = unknown> extends core.$ZodError<T> {
|
|
|
12
13
|
format(mapper?: AnyFunc): any {
|
|
13
14
|
return core.formatError(this, mapper);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
16
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
17
17
|
flatten(): core.$ZodFlattenedError<T>;
|
|
18
18
|
/** @deprecated Use the `z.treeifyError(err)` function instead. */
|
|
@@ -20,7 +20,6 @@ export class ZodError<T = unknown> extends core.$ZodError<T> {
|
|
|
20
20
|
flatten(mapper?: AnyFunc): core.$ZodFlattenedError<T> {
|
|
21
21
|
return core.flattenError(this, mapper);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
23
|
/** @deprecated Push directly to `.issues` instead. */
|
|
25
24
|
addIssue(issue: core.$ZodIssue): void {
|
|
26
25
|
this.issues.push(issue);
|
|
@@ -29,7 +28,6 @@ export class ZodError<T = unknown> extends core.$ZodError<T> {
|
|
|
29
28
|
addIssues(issues: core.$ZodIssue[]): void {
|
|
30
29
|
this.issues.push(...issues);
|
|
31
30
|
}
|
|
32
|
-
|
|
33
31
|
/** @deprecated Check `err.issues.length === 0` instead. */
|
|
34
32
|
get isEmpty(): boolean {
|
|
35
33
|
return this.issues.length === 0;
|
package/src/schemas.ts
CHANGED
|
@@ -70,7 +70,7 @@ export interface ZodType<out Output = unknown, out Input = unknown> extends core
|
|
|
70
70
|
default(def: () => util.NoUndefined<core.output<this>>, params?: core.$ZodDefaultParams): ZodDefault<this>;
|
|
71
71
|
array(): ZodArray<this>;
|
|
72
72
|
or<T extends core.$ZodType>(option: T): ZodUnion<[this, T]>;
|
|
73
|
-
and<T extends core.$ZodType>(incoming: T): ZodIntersection<this, T>;
|
|
73
|
+
// and<T extends core.$ZodType>(incoming: T): ZodIntersection<this, T>;
|
|
74
74
|
transform<NewOut>(
|
|
75
75
|
transform: (arg: core.output<this>, ctx: RefinementCtx<core.output<this>>) => NewOut | Promise<NewOut>
|
|
76
76
|
): ZodPipe<this, ZodTransform<Awaited<NewOut>, core.output<this>>>;
|
|
@@ -135,7 +135,7 @@ export const ZodType: core.$constructor<ZodType> = /*@__PURE__*/ core.$construct
|
|
|
135
135
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
136
136
|
inst.array = () => array(inst);
|
|
137
137
|
inst.or = (arg) => union([inst, arg]);
|
|
138
|
-
inst.and = (arg) => intersection(inst, arg);
|
|
138
|
+
// inst.and = (arg) => intersection(inst, arg);
|
|
139
139
|
inst.transform = (tx) => pipe(inst, transform(tx as any)) as never;
|
|
140
140
|
inst.default = (def, params) => _default(inst, def, params);
|
|
141
141
|
// inst.coalesce = (def, params) => coalesce(inst, def, params);
|
|
@@ -224,6 +224,10 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
224
224
|
ipv4(params?: string | core.$ZodCheckIPv4Params): this;
|
|
225
225
|
/** @deprecated Use `z.ipv6()` instead. */
|
|
226
226
|
ipv6(params?: string | core.$ZodCheckIPv6Params): this;
|
|
227
|
+
/** @deprecated Use `z.cidrv4()` instead. */
|
|
228
|
+
cidrv4(params?: string | core.$ZodCheckCIDRv4Params): this;
|
|
229
|
+
/** @deprecated Use `z.cidrv6()` instead. */
|
|
230
|
+
cidrv6(params?: string | core.$ZodCheckCIDRv6Params): this;
|
|
227
231
|
/** @deprecated Use `z.e164()` instead. */
|
|
228
232
|
e164(params?: string | core.$ZodCheckE164Params): this;
|
|
229
233
|
|
|
@@ -303,6 +307,8 @@ export const ZodString: core.$constructor<ZodString> = /*@__PURE__*/ core.$const
|
|
|
303
307
|
// };
|
|
304
308
|
inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
|
|
305
309
|
inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
|
|
310
|
+
inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
|
|
311
|
+
inst.cidrv6 = (params) => inst.check(core._cidrv6(ZodCIDRv6, params));
|
|
306
312
|
inst.e164 = (params) => inst.check(core._e164(ZodE164, params));
|
|
307
313
|
|
|
308
314
|
// iso
|
|
@@ -557,6 +563,32 @@ export function ipv6(params?: string | core.$ZodIPv6Params): ZodIPv6 {
|
|
|
557
563
|
return core._ipv6(ZodIPv6, params);
|
|
558
564
|
}
|
|
559
565
|
|
|
566
|
+
// ZodCIDRv4
|
|
567
|
+
export interface ZodCIDRv4 extends ZodStringFormat<"cidrv4"> {
|
|
568
|
+
_zod: core.$ZodCIDRv4Internals;
|
|
569
|
+
}
|
|
570
|
+
export const ZodCIDRv4: core.$constructor<ZodCIDRv4> = /*@__PURE__*/ core.$constructor("ZodCIDRv4", (inst, def) => {
|
|
571
|
+
core.$ZodCIDRv4.init(inst, def);
|
|
572
|
+
ZodType.init(inst, def);
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
export function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodCIDRv4 {
|
|
576
|
+
return core._cidrv4(ZodCIDRv4, params);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// ZodCIDRv6
|
|
580
|
+
export interface ZodCIDRv6 extends ZodStringFormat<"cidrv6"> {
|
|
581
|
+
_zod: core.$ZodCIDRv6Internals;
|
|
582
|
+
}
|
|
583
|
+
export const ZodCIDRv6: core.$constructor<ZodCIDRv6> = /*@__PURE__*/ core.$constructor("ZodCIDRv6", (inst, def) => {
|
|
584
|
+
core.$ZodCIDRv6.init(inst, def);
|
|
585
|
+
ZodType.init(inst, def);
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
export function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodCIDRv6 {
|
|
589
|
+
return core._cidrv6(ZodCIDRv6, params);
|
|
590
|
+
}
|
|
591
|
+
|
|
560
592
|
// ZodBase64
|
|
561
593
|
export interface ZodBase64 extends ZodStringFormat<"base64"> {
|
|
562
594
|
_zod: core.$ZodBase64Internals;
|
|
@@ -1193,13 +1225,7 @@ export function looseInterface<T extends core.$ZodLooseShape>(
|
|
|
1193
1225
|
return new ZodInterface(def) as any;
|
|
1194
1226
|
}
|
|
1195
1227
|
|
|
1196
|
-
type MergeObjects<A extends ZodObject, B extends ZodObject> = ZodObject<
|
|
1197
|
-
util.ExtendShape<A["_zod"]["shape"], B["_zod"]["shape"]>,
|
|
1198
|
-
A["_zod"]["extra"] // & B['_zod']["extra"]
|
|
1199
|
-
>;
|
|
1200
|
-
|
|
1201
1228
|
// ZodObject
|
|
1202
|
-
|
|
1203
1229
|
export interface ZodObject<
|
|
1204
1230
|
// @ts-ignore cast variance
|
|
1205
1231
|
out Shape extends core.$ZodShape = core.$ZodShape,
|
|
@@ -1227,8 +1253,18 @@ export interface ZodObject<
|
|
|
1227
1253
|
/** @deprecated This is the default behavior. This method call is likely unnecessary. */
|
|
1228
1254
|
strip(): ZodObject<Shape, {}>;
|
|
1229
1255
|
|
|
1230
|
-
extend<U extends ZodObject>(
|
|
1231
|
-
|
|
1256
|
+
extend<U extends ZodObject>(
|
|
1257
|
+
shape: U
|
|
1258
|
+
): ZodObject<
|
|
1259
|
+
util.ExtendShape<Shape, U["_zod"]["shape"]>,
|
|
1260
|
+
Extra // & B['_zod']["extra"]
|
|
1261
|
+
>;
|
|
1262
|
+
extend<U extends core.$ZodShape>(
|
|
1263
|
+
shape: U
|
|
1264
|
+
): ZodObject<
|
|
1265
|
+
util.ExtendShape<Shape, U>,
|
|
1266
|
+
Extra // & B['_zod']["extra"]
|
|
1267
|
+
>;
|
|
1232
1268
|
|
|
1233
1269
|
// merge
|
|
1234
1270
|
/** @deprecated Use `A.extend(B)` */
|
|
@@ -2287,7 +2323,7 @@ export { _instanceof as instanceof };
|
|
|
2287
2323
|
|
|
2288
2324
|
// stringbool
|
|
2289
2325
|
export const stringbool: (_params?: core.$ZodStringBoolParams) => ZodPipe<ZodUnknown, ZodBoolean> =
|
|
2290
|
-
core._stringbool.bind(null, {
|
|
2326
|
+
/*@__PURE__*/ core._stringbool.bind(null, {
|
|
2291
2327
|
Pipe: ZodPipe,
|
|
2292
2328
|
Boolean: ZodBoolean,
|
|
2293
2329
|
Unknown: ZodUnknown,
|