zod 4.0.0-beta.20250420T053007 → 4.0.0-beta.20250430T185432
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/schemas.d.ts +21 -20
- package/dist/commonjs/schemas.js +28 -32
- package/dist/esm/schemas.d.ts +21 -20
- package/dist/esm/schemas.js +26 -30
- package/package.json +2 -2
- package/src/schemas.ts +57 -59
|
@@ -57,6 +57,26 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
57
57
|
format: string | null;
|
|
58
58
|
minLength: number | null;
|
|
59
59
|
maxLength: number | null;
|
|
60
|
+
regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
|
|
61
|
+
includes(value: string, params?: {
|
|
62
|
+
message?: string;
|
|
63
|
+
position?: number;
|
|
64
|
+
}): this;
|
|
65
|
+
startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
|
|
66
|
+
endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
|
|
67
|
+
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
68
|
+
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
69
|
+
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
70
|
+
nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
|
|
71
|
+
lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
|
|
72
|
+
uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
|
|
73
|
+
trim(): this;
|
|
74
|
+
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
|
75
|
+
toLowerCase(): this;
|
|
76
|
+
toUpperCase(): this;
|
|
77
|
+
}
|
|
78
|
+
export declare const _ZodString: core.$constructor<_ZodString>;
|
|
79
|
+
export interface ZodString extends _ZodString<string> {
|
|
60
80
|
/** @deprecated Use `z.email()` instead. */
|
|
61
81
|
email(params?: string | core.$ZodCheckEmailParams): this;
|
|
62
82
|
/** @deprecated Use `z.url()` instead. */
|
|
@@ -111,29 +131,10 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
111
131
|
time(params?: string | core.$ZodCheckISOTimeParams): this;
|
|
112
132
|
/** @deprecated Use `z.iso.duration()` instead. */
|
|
113
133
|
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
114
|
-
regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
|
|
115
|
-
includes(value: string, params?: {
|
|
116
|
-
message?: string;
|
|
117
|
-
position?: number;
|
|
118
|
-
}): this;
|
|
119
|
-
startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
|
|
120
|
-
endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
|
|
121
|
-
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
122
|
-
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
123
|
-
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
124
|
-
nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
|
|
125
|
-
lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
|
|
126
|
-
uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
|
|
127
|
-
trim(): this;
|
|
128
|
-
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
|
129
|
-
toLowerCase(): this;
|
|
130
|
-
toUpperCase(): this;
|
|
131
|
-
}
|
|
132
|
-
export interface ZodString extends _ZodString<string> {
|
|
133
134
|
}
|
|
134
135
|
export declare const ZodString: core.$constructor<ZodString>;
|
|
135
136
|
export declare function string(params?: string | core.$ZodStringParams): ZodString;
|
|
136
|
-
export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends
|
|
137
|
+
export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends _ZodString {
|
|
137
138
|
_zod: core.$ZodStringFormatInternals<Format>;
|
|
138
139
|
}
|
|
139
140
|
export declare const ZodStringFormat: core.$constructor<ZodStringFormat>;
|
package/dist/commonjs/schemas.js
CHANGED
|
@@ -23,8 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
27
|
-
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 = exports.ZodFile = void 0;
|
|
26
|
+
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.ZodBase64URL = 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._ZodString = exports.ZodType = exports.coerce = exports.iso = void 0;
|
|
27
|
+
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 = exports.ZodFile = exports.ZodLiteral = void 0;
|
|
28
28
|
exports.string = string;
|
|
29
29
|
exports.email = email;
|
|
30
30
|
exports.guid = guid;
|
|
@@ -134,7 +134,7 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
|
134
134
|
],
|
|
135
135
|
});
|
|
136
136
|
};
|
|
137
|
-
inst.clone = (_def) => core.clone(inst, _def
|
|
137
|
+
inst.clone = (_def) => core.clone(inst, _def);
|
|
138
138
|
inst.brand = () => inst;
|
|
139
139
|
inst.register = ((reg, meta) => {
|
|
140
140
|
reg.add(inst, meta);
|
|
@@ -167,8 +167,8 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
|
167
167
|
// meta
|
|
168
168
|
inst.describe = (description) => {
|
|
169
169
|
const cl = inst.clone();
|
|
170
|
-
const meta = core.globalRegistry.get(inst) ?? {};
|
|
171
|
-
meta.
|
|
170
|
+
const meta = { ...(core.globalRegistry.get(inst) ?? {}), description };
|
|
171
|
+
delete meta.id; // do not inherit
|
|
172
172
|
core.globalRegistry.add(cl, meta);
|
|
173
173
|
return cl;
|
|
174
174
|
};
|
|
@@ -190,12 +190,32 @@ exports.ZodType = core.$constructor("ZodType", (inst, def) => {
|
|
|
190
190
|
inst.isNullable = () => inst.safeParse(null).success;
|
|
191
191
|
return inst;
|
|
192
192
|
});
|
|
193
|
-
exports.
|
|
193
|
+
exports._ZodString = core.$constructor("_ZodString", (inst, def) => {
|
|
194
194
|
core.$ZodString.init(inst, def);
|
|
195
195
|
exports.ZodType.init(inst, def);
|
|
196
196
|
inst.format = inst._zod.computed.format ?? null;
|
|
197
197
|
inst.minLength = inst._zod.computed.minimum ?? null;
|
|
198
198
|
inst.maxLength = inst._zod.computed.maximum ?? null;
|
|
199
|
+
// validations
|
|
200
|
+
inst.regex = (...args) => inst.check(checks.regex(...args));
|
|
201
|
+
inst.includes = (...args) => inst.check(checks.includes(...args));
|
|
202
|
+
inst.startsWith = (params) => inst.check(checks.startsWith(params));
|
|
203
|
+
inst.endsWith = (params) => inst.check(checks.endsWith(params));
|
|
204
|
+
inst.min = (...args) => inst.check(checks.minLength(...args));
|
|
205
|
+
inst.max = (...args) => inst.check(checks.maxLength(...args));
|
|
206
|
+
inst.length = (...args) => inst.check(checks.length(...args));
|
|
207
|
+
inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
|
|
208
|
+
inst.lowercase = (params) => inst.check(checks.lowercase(params));
|
|
209
|
+
inst.uppercase = (params) => inst.check(checks.uppercase(params));
|
|
210
|
+
// transforms
|
|
211
|
+
inst.trim = () => inst.check(checks.trim());
|
|
212
|
+
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
|
213
|
+
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
|
214
|
+
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
|
215
|
+
});
|
|
216
|
+
exports.ZodString = core.$constructor("ZodString", (inst, def) => {
|
|
217
|
+
core.$ZodString.init(inst, def);
|
|
218
|
+
exports._ZodString.init(inst, def);
|
|
199
219
|
inst.email = (params) => inst.check(core._email(exports.ZodEmail, params));
|
|
200
220
|
inst.url = (params) => inst.check(core._url(exports.ZodURL, params));
|
|
201
221
|
inst.jwt = (params) => inst.check(core._jwt(exports.ZodJWT, params));
|
|
@@ -212,16 +232,8 @@ exports.ZodString = core.$constructor("ZodString", (inst, def) => {
|
|
|
212
232
|
inst.ulid = (params) => inst.check(core._ulid(exports.ZodULID, params));
|
|
213
233
|
inst.base64 = (params) => inst.check(core._base64(exports.ZodBase64, params));
|
|
214
234
|
inst.base64url = (params) => inst.check(core._base64url(exports.ZodBase64URL, params));
|
|
215
|
-
// inst.jsonString = (params) => inst.check(core._jsonString(Zodinst,params));
|
|
216
|
-
// inst.json = (params) => inst.check(core._jsonString(Zodinst,params));
|
|
217
235
|
inst.xid = (params) => inst.check(core._xid(exports.ZodXID, params));
|
|
218
236
|
inst.ksuid = (params) => inst.check(core._ksuid(exports.ZodKSUID, params));
|
|
219
|
-
// inst.ip = (params) => {
|
|
220
|
-
// const version = (params ?? {} as any)?.version;
|
|
221
|
-
// if (version === "v4") return inst.check(core._ipv4(ZodIPv4, params));
|
|
222
|
-
// if (version === "v6") return inst.check(core._ipv6(ZodIPv6, params as any));
|
|
223
|
-
// return union([inst.ipv4(params), inst.ipv6(params as any)]);
|
|
224
|
-
// };
|
|
225
237
|
inst.ipv4 = (params) => inst.check(core._ipv4(exports.ZodIPv4, params));
|
|
226
238
|
inst.ipv6 = (params) => inst.check(core._ipv6(exports.ZodIPv6, params));
|
|
227
239
|
inst.cidrv4 = (params) => inst.check(core._cidrv4(exports.ZodCIDRv4, params));
|
|
@@ -232,29 +244,13 @@ exports.ZodString = core.$constructor("ZodString", (inst, def) => {
|
|
|
232
244
|
inst.date = (params) => inst.check(iso.date(params));
|
|
233
245
|
inst.time = (params) => inst.check(iso.time(params));
|
|
234
246
|
inst.duration = (params) => inst.check(iso.duration(params));
|
|
235
|
-
// validations
|
|
236
|
-
inst.regex = (...args) => inst.check(checks.regex(...args));
|
|
237
|
-
inst.includes = (...args) => inst.check(checks.includes(...args));
|
|
238
|
-
inst.startsWith = (params) => inst.check(checks.startsWith(params));
|
|
239
|
-
inst.endsWith = (params) => inst.check(checks.endsWith(params));
|
|
240
|
-
inst.min = (...args) => inst.check(checks.minLength(...args));
|
|
241
|
-
inst.max = (...args) => inst.check(checks.maxLength(...args));
|
|
242
|
-
inst.length = (...args) => inst.check(checks.length(...args));
|
|
243
|
-
inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
|
|
244
|
-
inst.lowercase = (params) => inst.check(checks.lowercase(params));
|
|
245
|
-
inst.uppercase = (params) => inst.check(checks.uppercase(params));
|
|
246
|
-
// transforms
|
|
247
|
-
inst.trim = () => inst.check(checks.trim());
|
|
248
|
-
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
|
249
|
-
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
|
250
|
-
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
|
251
247
|
});
|
|
252
248
|
function string(params) {
|
|
253
249
|
return core._string(exports.ZodString, params);
|
|
254
250
|
}
|
|
255
251
|
exports.ZodStringFormat = core.$constructor("ZodStringFormat", (inst, def) => {
|
|
256
252
|
core.$ZodStringFormat.init(inst, def);
|
|
257
|
-
exports.
|
|
253
|
+
exports._ZodString.init(inst, def);
|
|
258
254
|
});
|
|
259
255
|
exports.ZodEmail = core.$constructor("ZodEmail", (inst, def) => {
|
|
260
256
|
// ZodStringFormat.init(inst, def);
|
|
@@ -448,7 +444,7 @@ function number(params) {
|
|
|
448
444
|
}
|
|
449
445
|
exports.ZodNumberFormat = core.$constructor("ZodNumberFormat", (inst, def) => {
|
|
450
446
|
core.$ZodNumberFormat.init(inst, def);
|
|
451
|
-
exports.
|
|
447
|
+
exports.ZodNumber.init(inst, def);
|
|
452
448
|
});
|
|
453
449
|
function int(params) {
|
|
454
450
|
return core._int(exports.ZodNumberFormat, params);
|
package/dist/esm/schemas.d.ts
CHANGED
|
@@ -57,6 +57,26 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
57
57
|
format: string | null;
|
|
58
58
|
minLength: number | null;
|
|
59
59
|
maxLength: number | null;
|
|
60
|
+
regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
|
|
61
|
+
includes(value: string, params?: {
|
|
62
|
+
message?: string;
|
|
63
|
+
position?: number;
|
|
64
|
+
}): this;
|
|
65
|
+
startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
|
|
66
|
+
endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
|
|
67
|
+
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
68
|
+
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
69
|
+
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
70
|
+
nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
|
|
71
|
+
lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
|
|
72
|
+
uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
|
|
73
|
+
trim(): this;
|
|
74
|
+
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
|
75
|
+
toLowerCase(): this;
|
|
76
|
+
toUpperCase(): this;
|
|
77
|
+
}
|
|
78
|
+
export declare const _ZodString: core.$constructor<_ZodString>;
|
|
79
|
+
export interface ZodString extends _ZodString<string> {
|
|
60
80
|
/** @deprecated Use `z.email()` instead. */
|
|
61
81
|
email(params?: string | core.$ZodCheckEmailParams): this;
|
|
62
82
|
/** @deprecated Use `z.url()` instead. */
|
|
@@ -111,29 +131,10 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
111
131
|
time(params?: string | core.$ZodCheckISOTimeParams): this;
|
|
112
132
|
/** @deprecated Use `z.iso.duration()` instead. */
|
|
113
133
|
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
114
|
-
regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
|
|
115
|
-
includes(value: string, params?: {
|
|
116
|
-
message?: string;
|
|
117
|
-
position?: number;
|
|
118
|
-
}): this;
|
|
119
|
-
startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
|
|
120
|
-
endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
|
|
121
|
-
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
122
|
-
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
123
|
-
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
124
|
-
nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
|
|
125
|
-
lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
|
|
126
|
-
uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
|
|
127
|
-
trim(): this;
|
|
128
|
-
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
|
129
|
-
toLowerCase(): this;
|
|
130
|
-
toUpperCase(): this;
|
|
131
|
-
}
|
|
132
|
-
export interface ZodString extends _ZodString<string> {
|
|
133
134
|
}
|
|
134
135
|
export declare const ZodString: core.$constructor<ZodString>;
|
|
135
136
|
export declare function string(params?: string | core.$ZodStringParams): ZodString;
|
|
136
|
-
export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends
|
|
137
|
+
export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends _ZodString {
|
|
137
138
|
_zod: core.$ZodStringFormatInternals<Format>;
|
|
138
139
|
}
|
|
139
140
|
export declare const ZodStringFormat: core.$constructor<ZodStringFormat>;
|
package/dist/esm/schemas.js
CHANGED
|
@@ -19,7 +19,7 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
19
19
|
],
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
inst.clone = (_def) => core.clone(inst, _def
|
|
22
|
+
inst.clone = (_def) => core.clone(inst, _def);
|
|
23
23
|
inst.brand = () => inst;
|
|
24
24
|
inst.register = ((reg, meta) => {
|
|
25
25
|
reg.add(inst, meta);
|
|
@@ -52,8 +52,8 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
52
52
|
// meta
|
|
53
53
|
inst.describe = (description) => {
|
|
54
54
|
const cl = inst.clone();
|
|
55
|
-
const meta = core.globalRegistry.get(inst) ?? {};
|
|
56
|
-
meta.
|
|
55
|
+
const meta = { ...(core.globalRegistry.get(inst) ?? {}), description };
|
|
56
|
+
delete meta.id; // do not inherit
|
|
57
57
|
core.globalRegistry.add(cl, meta);
|
|
58
58
|
return cl;
|
|
59
59
|
};
|
|
@@ -75,12 +75,32 @@ export const ZodType = /*@__PURE__*/ core.$constructor("ZodType", (inst, def) =>
|
|
|
75
75
|
inst.isNullable = () => inst.safeParse(null).success;
|
|
76
76
|
return inst;
|
|
77
77
|
});
|
|
78
|
-
export const
|
|
78
|
+
export const _ZodString = /*@__PURE__*/ core.$constructor("_ZodString", (inst, def) => {
|
|
79
79
|
core.$ZodString.init(inst, def);
|
|
80
80
|
ZodType.init(inst, def);
|
|
81
81
|
inst.format = inst._zod.computed.format ?? null;
|
|
82
82
|
inst.minLength = inst._zod.computed.minimum ?? null;
|
|
83
83
|
inst.maxLength = inst._zod.computed.maximum ?? null;
|
|
84
|
+
// validations
|
|
85
|
+
inst.regex = (...args) => inst.check(checks.regex(...args));
|
|
86
|
+
inst.includes = (...args) => inst.check(checks.includes(...args));
|
|
87
|
+
inst.startsWith = (params) => inst.check(checks.startsWith(params));
|
|
88
|
+
inst.endsWith = (params) => inst.check(checks.endsWith(params));
|
|
89
|
+
inst.min = (...args) => inst.check(checks.minLength(...args));
|
|
90
|
+
inst.max = (...args) => inst.check(checks.maxLength(...args));
|
|
91
|
+
inst.length = (...args) => inst.check(checks.length(...args));
|
|
92
|
+
inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
|
|
93
|
+
inst.lowercase = (params) => inst.check(checks.lowercase(params));
|
|
94
|
+
inst.uppercase = (params) => inst.check(checks.uppercase(params));
|
|
95
|
+
// transforms
|
|
96
|
+
inst.trim = () => inst.check(checks.trim());
|
|
97
|
+
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
|
98
|
+
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
|
99
|
+
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
|
100
|
+
});
|
|
101
|
+
export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
|
|
102
|
+
core.$ZodString.init(inst, def);
|
|
103
|
+
_ZodString.init(inst, def);
|
|
84
104
|
inst.email = (params) => inst.check(core._email(ZodEmail, params));
|
|
85
105
|
inst.url = (params) => inst.check(core._url(ZodURL, params));
|
|
86
106
|
inst.jwt = (params) => inst.check(core._jwt(ZodJWT, params));
|
|
@@ -97,16 +117,8 @@ export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def
|
|
|
97
117
|
inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));
|
|
98
118
|
inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));
|
|
99
119
|
inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));
|
|
100
|
-
// inst.jsonString = (params) => inst.check(core._jsonString(Zodinst,params));
|
|
101
|
-
// inst.json = (params) => inst.check(core._jsonString(Zodinst,params));
|
|
102
120
|
inst.xid = (params) => inst.check(core._xid(ZodXID, params));
|
|
103
121
|
inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));
|
|
104
|
-
// inst.ip = (params) => {
|
|
105
|
-
// const version = (params ?? {} as any)?.version;
|
|
106
|
-
// if (version === "v4") return inst.check(core._ipv4(ZodIPv4, params));
|
|
107
|
-
// if (version === "v6") return inst.check(core._ipv6(ZodIPv6, params as any));
|
|
108
|
-
// return union([inst.ipv4(params), inst.ipv6(params as any)]);
|
|
109
|
-
// };
|
|
110
122
|
inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
|
|
111
123
|
inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
|
|
112
124
|
inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
|
|
@@ -117,29 +129,13 @@ export const ZodString = /*@__PURE__*/ core.$constructor("ZodString", (inst, def
|
|
|
117
129
|
inst.date = (params) => inst.check(iso.date(params));
|
|
118
130
|
inst.time = (params) => inst.check(iso.time(params));
|
|
119
131
|
inst.duration = (params) => inst.check(iso.duration(params));
|
|
120
|
-
// validations
|
|
121
|
-
inst.regex = (...args) => inst.check(checks.regex(...args));
|
|
122
|
-
inst.includes = (...args) => inst.check(checks.includes(...args));
|
|
123
|
-
inst.startsWith = (params) => inst.check(checks.startsWith(params));
|
|
124
|
-
inst.endsWith = (params) => inst.check(checks.endsWith(params));
|
|
125
|
-
inst.min = (...args) => inst.check(checks.minLength(...args));
|
|
126
|
-
inst.max = (...args) => inst.check(checks.maxLength(...args));
|
|
127
|
-
inst.length = (...args) => inst.check(checks.length(...args));
|
|
128
|
-
inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
|
|
129
|
-
inst.lowercase = (params) => inst.check(checks.lowercase(params));
|
|
130
|
-
inst.uppercase = (params) => inst.check(checks.uppercase(params));
|
|
131
|
-
// transforms
|
|
132
|
-
inst.trim = () => inst.check(checks.trim());
|
|
133
|
-
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
|
134
|
-
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
|
135
|
-
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
|
136
132
|
});
|
|
137
133
|
export function string(params) {
|
|
138
134
|
return core._string(ZodString, params);
|
|
139
135
|
}
|
|
140
136
|
export const ZodStringFormat = /*@__PURE__*/ core.$constructor("ZodStringFormat", (inst, def) => {
|
|
141
137
|
core.$ZodStringFormat.init(inst, def);
|
|
142
|
-
|
|
138
|
+
_ZodString.init(inst, def);
|
|
143
139
|
});
|
|
144
140
|
export const ZodEmail = /*@__PURE__*/ core.$constructor("ZodEmail", (inst, def) => {
|
|
145
141
|
// ZodStringFormat.init(inst, def);
|
|
@@ -333,7 +329,7 @@ export function number(params) {
|
|
|
333
329
|
}
|
|
334
330
|
export const ZodNumberFormat = /*@__PURE__*/ core.$constructor("ZodNumberFormat", (inst, def) => {
|
|
335
331
|
core.$ZodNumberFormat.init(inst, def);
|
|
336
|
-
|
|
332
|
+
ZodNumber.init(inst, def);
|
|
337
333
|
});
|
|
338
334
|
export function int(params) {
|
|
339
335
|
return core._int(ZodNumberFormat, params);
|
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.20250430T185432",
|
|
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.
|
|
73
|
+
"@zod/core": "0.10.0"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
76
|
"clean": "rm -rf dist",
|
package/src/schemas.ts
CHANGED
|
@@ -113,7 +113,7 @@ export const ZodType: core.$constructor<ZodType> = /*@__PURE__*/ core.$construct
|
|
|
113
113
|
],
|
|
114
114
|
});
|
|
115
115
|
};
|
|
116
|
-
inst.clone = (_def) => core.clone(inst, _def
|
|
116
|
+
inst.clone = (_def) => core.clone(inst, _def);
|
|
117
117
|
inst.brand = () => inst as any;
|
|
118
118
|
inst.register = ((reg: any, meta: any) => {
|
|
119
119
|
reg.add(inst, meta);
|
|
@@ -150,8 +150,8 @@ export const ZodType: core.$constructor<ZodType> = /*@__PURE__*/ core.$construct
|
|
|
150
150
|
// meta
|
|
151
151
|
inst.describe = (description) => {
|
|
152
152
|
const cl = inst.clone();
|
|
153
|
-
const meta = core.globalRegistry.get(inst) ?? {};
|
|
154
|
-
meta.
|
|
153
|
+
const meta = { ...(core.globalRegistry.get(inst) ?? {}), description };
|
|
154
|
+
delete meta.id; // do not inherit
|
|
155
155
|
core.globalRegistry.add(cl, meta);
|
|
156
156
|
return cl;
|
|
157
157
|
};
|
|
@@ -182,6 +182,56 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
182
182
|
minLength: number | null;
|
|
183
183
|
maxLength: number | null;
|
|
184
184
|
|
|
185
|
+
// /** @deprecated Use `z.jsonString()` instead. */
|
|
186
|
+
// json(params?: string | core.$ZodCheckJSONStringParams): this;
|
|
187
|
+
|
|
188
|
+
// miscellaneous checks
|
|
189
|
+
regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
|
|
190
|
+
includes(value: string, params?: { message?: string; position?: number }): this;
|
|
191
|
+
startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
|
|
192
|
+
endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
|
|
193
|
+
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
194
|
+
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
195
|
+
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
196
|
+
nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
|
|
197
|
+
lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
|
|
198
|
+
uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
|
|
199
|
+
|
|
200
|
+
// transforms
|
|
201
|
+
trim(): this;
|
|
202
|
+
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
|
203
|
+
toLowerCase(): this;
|
|
204
|
+
toUpperCase(): this;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export const _ZodString: core.$constructor<_ZodString> = /*@__PURE__*/ core.$constructor("_ZodString", (inst, def) => {
|
|
208
|
+
core.$ZodString.init(inst, def);
|
|
209
|
+
ZodType.init(inst, def);
|
|
210
|
+
|
|
211
|
+
inst.format = inst._zod.computed.format ?? null;
|
|
212
|
+
inst.minLength = inst._zod.computed.minimum ?? null;
|
|
213
|
+
inst.maxLength = inst._zod.computed.maximum ?? null;
|
|
214
|
+
|
|
215
|
+
// validations
|
|
216
|
+
inst.regex = (...args) => inst.check(checks.regex(...args));
|
|
217
|
+
inst.includes = (...args) => inst.check(checks.includes(...args));
|
|
218
|
+
inst.startsWith = (params) => inst.check(checks.startsWith(params));
|
|
219
|
+
inst.endsWith = (params) => inst.check(checks.endsWith(params));
|
|
220
|
+
inst.min = (...args) => inst.check(checks.minLength(...args));
|
|
221
|
+
inst.max = (...args) => inst.check(checks.maxLength(...args));
|
|
222
|
+
inst.length = (...args) => inst.check(checks.length(...args));
|
|
223
|
+
inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
|
|
224
|
+
inst.lowercase = (params) => inst.check(checks.lowercase(params));
|
|
225
|
+
inst.uppercase = (params) => inst.check(checks.uppercase(params));
|
|
226
|
+
|
|
227
|
+
// transforms
|
|
228
|
+
inst.trim = () => inst.check(checks.trim());
|
|
229
|
+
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
|
230
|
+
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
|
231
|
+
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
export interface ZodString extends _ZodString<string> {
|
|
185
235
|
// string format checks
|
|
186
236
|
// email(): ZodString;
|
|
187
237
|
// email(params?: string): ZodString;
|
|
@@ -254,37 +304,11 @@ export interface _ZodString<Input = unknown> extends ZodType {
|
|
|
254
304
|
): this;
|
|
255
305
|
/** @deprecated Use `z.iso.duration()` instead. */
|
|
256
306
|
duration(params?: string | core.$ZodCheckISODurationParams): this;
|
|
257
|
-
|
|
258
|
-
// /** @deprecated Use `z.jsonString()` instead. */
|
|
259
|
-
// json(params?: string | core.$ZodCheckJSONStringParams): this;
|
|
260
|
-
|
|
261
|
-
// miscellaneous checks
|
|
262
|
-
regex(regex: RegExp, params?: string | core.$ZodCheckRegexParams): this;
|
|
263
|
-
includes(value: string, params?: { message?: string; position?: number }): this;
|
|
264
|
-
startsWith(value: string, params?: string | core.$ZodCheckStartsWithParams): this;
|
|
265
|
-
endsWith(value: string, params?: string | core.$ZodCheckEndsWithParams): this;
|
|
266
|
-
min(minLength: number, params?: string | core.$ZodCheckMinLengthParams): this;
|
|
267
|
-
max(maxLength: number, params?: string | core.$ZodCheckMaxLengthParams): this;
|
|
268
|
-
length(len: number, params?: string | core.$ZodCheckLengthEqualsParams): this;
|
|
269
|
-
nonempty(params?: string | core.$ZodCheckMinLengthParams): this;
|
|
270
|
-
lowercase(params?: string | core.$ZodCheckLowerCaseParams): this;
|
|
271
|
-
uppercase(params?: string | core.$ZodCheckUpperCaseParams): this;
|
|
272
|
-
|
|
273
|
-
// transforms
|
|
274
|
-
trim(): this;
|
|
275
|
-
normalize(form?: "NFC" | "NFD" | "NFKC" | "NFKD" | (string & {})): this;
|
|
276
|
-
toLowerCase(): this;
|
|
277
|
-
toUpperCase(): this;
|
|
278
307
|
}
|
|
279
308
|
|
|
280
|
-
export interface ZodString extends _ZodString<string> {}
|
|
281
309
|
export const ZodString: core.$constructor<ZodString> = /*@__PURE__*/ core.$constructor("ZodString", (inst, def) => {
|
|
282
310
|
core.$ZodString.init(inst, def);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
inst.format = inst._zod.computed.format ?? null;
|
|
286
|
-
inst.minLength = inst._zod.computed.minimum ?? null;
|
|
287
|
-
inst.maxLength = inst._zod.computed.maximum ?? null;
|
|
311
|
+
_ZodString.init(inst, def);
|
|
288
312
|
|
|
289
313
|
inst.email = (params) => inst.check(core._email(ZodEmail, params));
|
|
290
314
|
inst.url = (params) => inst.check(core._url(ZodURL, params));
|
|
@@ -302,16 +326,8 @@ export const ZodString: core.$constructor<ZodString> = /*@__PURE__*/ core.$const
|
|
|
302
326
|
inst.ulid = (params) => inst.check(core._ulid(ZodULID, params));
|
|
303
327
|
inst.base64 = (params) => inst.check(core._base64(ZodBase64, params));
|
|
304
328
|
inst.base64url = (params) => inst.check(core._base64url(ZodBase64URL, params));
|
|
305
|
-
// inst.jsonString = (params) => inst.check(core._jsonString(Zodinst,params));
|
|
306
|
-
// inst.json = (params) => inst.check(core._jsonString(Zodinst,params));
|
|
307
329
|
inst.xid = (params) => inst.check(core._xid(ZodXID, params));
|
|
308
330
|
inst.ksuid = (params) => inst.check(core._ksuid(ZodKSUID, params));
|
|
309
|
-
// inst.ip = (params) => {
|
|
310
|
-
// const version = (params ?? {} as any)?.version;
|
|
311
|
-
// if (version === "v4") return inst.check(core._ipv4(ZodIPv4, params));
|
|
312
|
-
// if (version === "v6") return inst.check(core._ipv6(ZodIPv6, params as any));
|
|
313
|
-
// return union([inst.ipv4(params), inst.ipv6(params as any)]);
|
|
314
|
-
// };
|
|
315
331
|
inst.ipv4 = (params) => inst.check(core._ipv4(ZodIPv4, params));
|
|
316
332
|
inst.ipv6 = (params) => inst.check(core._ipv6(ZodIPv6, params));
|
|
317
333
|
inst.cidrv4 = (params) => inst.check(core._cidrv4(ZodCIDRv4, params));
|
|
@@ -323,24 +339,6 @@ export const ZodString: core.$constructor<ZodString> = /*@__PURE__*/ core.$const
|
|
|
323
339
|
inst.date = (params) => inst.check(iso.date(params as any));
|
|
324
340
|
inst.time = (params) => inst.check(iso.time(params as any));
|
|
325
341
|
inst.duration = (params) => inst.check(iso.duration(params as any));
|
|
326
|
-
|
|
327
|
-
// validations
|
|
328
|
-
inst.regex = (...args) => inst.check(checks.regex(...args));
|
|
329
|
-
inst.includes = (...args) => inst.check(checks.includes(...args));
|
|
330
|
-
inst.startsWith = (params) => inst.check(checks.startsWith(params));
|
|
331
|
-
inst.endsWith = (params) => inst.check(checks.endsWith(params));
|
|
332
|
-
inst.min = (...args) => inst.check(checks.minLength(...args));
|
|
333
|
-
inst.max = (...args) => inst.check(checks.maxLength(...args));
|
|
334
|
-
inst.length = (...args) => inst.check(checks.length(...args));
|
|
335
|
-
inst.nonempty = (...args) => inst.check(checks.minLength(1, ...args));
|
|
336
|
-
inst.lowercase = (params) => inst.check(checks.lowercase(params));
|
|
337
|
-
inst.uppercase = (params) => inst.check(checks.uppercase(params));
|
|
338
|
-
|
|
339
|
-
// transforms
|
|
340
|
-
inst.trim = () => inst.check(checks.trim());
|
|
341
|
-
inst.normalize = (...args) => inst.check(checks.normalize(...args));
|
|
342
|
-
inst.toLowerCase = () => inst.check(checks.toLowerCase());
|
|
343
|
-
inst.toUpperCase = () => inst.check(checks.toUpperCase());
|
|
344
342
|
});
|
|
345
343
|
|
|
346
344
|
export function string(params?: string | core.$ZodStringParams): ZodString {
|
|
@@ -348,14 +346,14 @@ export function string(params?: string | core.$ZodStringParams): ZodString {
|
|
|
348
346
|
}
|
|
349
347
|
|
|
350
348
|
// ZodStringFormat
|
|
351
|
-
export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends
|
|
349
|
+
export interface ZodStringFormat<Format extends core.$ZodStringFormats = core.$ZodStringFormats> extends _ZodString {
|
|
352
350
|
_zod: core.$ZodStringFormatInternals<Format>;
|
|
353
351
|
}
|
|
354
352
|
export const ZodStringFormat: core.$constructor<ZodStringFormat> = /*@__PURE__*/ core.$constructor(
|
|
355
353
|
"ZodStringFormat",
|
|
356
354
|
(inst, def) => {
|
|
357
355
|
core.$ZodStringFormat.init(inst, def);
|
|
358
|
-
|
|
356
|
+
_ZodString.init(inst, def);
|
|
359
357
|
}
|
|
360
358
|
);
|
|
361
359
|
|
|
@@ -733,7 +731,7 @@ export const ZodNumberFormat: core.$constructor<ZodNumberFormat> = /*@__PURE__*/
|
|
|
733
731
|
"ZodNumberFormat",
|
|
734
732
|
(inst, def) => {
|
|
735
733
|
core.$ZodNumberFormat.init(inst, def);
|
|
736
|
-
|
|
734
|
+
ZodNumber.init(inst, def);
|
|
737
735
|
}
|
|
738
736
|
);
|
|
739
737
|
|