zod 3.25.68-beta.0 → 3.25.68-beta.2
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/README.md +2 -2
- package/package.json +22 -6
- package/v3/ZodError.cjs +3 -2
- package/v3/ZodError.js +3 -2
- package/v3/types.cjs +2 -0
- package/v3/types.js +2 -0
- package/v4/core/schemas.cjs +2 -2
- package/v4/core/schemas.js +2 -2
- package/v4/core/util.cjs +1 -4
- package/v4/core/util.js +1 -4
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
Zod is a TypeScript-first validation library. Define a schema and parse some data with it. You'll get back a strongly typed, validated result.
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
import
|
|
61
|
+
import * as z from "zod/v4";
|
|
62
62
|
|
|
63
63
|
const User = z.object({
|
|
64
64
|
name: z.string(),
|
|
@@ -104,7 +104,7 @@ npm install zod
|
|
|
104
104
|
Before you can do anything else, you need to define a schema. For the purposes of this guide, we'll use a simple object schema.
|
|
105
105
|
|
|
106
106
|
```ts
|
|
107
|
-
import
|
|
107
|
+
import * as z from "zod/v4";
|
|
108
108
|
|
|
109
109
|
const Player = z.object({
|
|
110
110
|
username: z.string(),
|
package/package.json
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zod",
|
|
3
|
-
"version": "3.25.68-beta.
|
|
3
|
+
"version": "3.25.68-beta.2",
|
|
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",
|
|
7
|
-
"files": [
|
|
7
|
+
"files": [
|
|
8
|
+
"**/*.js",
|
|
9
|
+
"**/*.mjs",
|
|
10
|
+
"**/*.cjs",
|
|
11
|
+
"**/*.d.ts",
|
|
12
|
+
"**/*.d.mts",
|
|
13
|
+
"**/*.d.cts"
|
|
14
|
+
],
|
|
8
15
|
"funding": "https://github.com/sponsors/colinhacks",
|
|
9
16
|
"homepage": "https://zod.dev",
|
|
10
|
-
"keywords": [
|
|
17
|
+
"keywords": [
|
|
18
|
+
"typescript",
|
|
19
|
+
"schema",
|
|
20
|
+
"validation",
|
|
21
|
+
"type",
|
|
22
|
+
"inference"
|
|
23
|
+
],
|
|
11
24
|
"license": "MIT",
|
|
12
25
|
"sideEffects": false,
|
|
13
26
|
"main": "./index.cjs",
|
|
@@ -25,7 +38,9 @@
|
|
|
25
38
|
"./v4/locales": "./v4/locales/index.ts",
|
|
26
39
|
"./v4/locales/*": "./v4/locales/*"
|
|
27
40
|
},
|
|
28
|
-
"sourceDialects": [
|
|
41
|
+
"sourceDialects": [
|
|
42
|
+
"@zod/source"
|
|
43
|
+
]
|
|
29
44
|
},
|
|
30
45
|
"exports": {
|
|
31
46
|
"./package.json": "./package.json",
|
|
@@ -73,6 +88,7 @@
|
|
|
73
88
|
},
|
|
74
89
|
"./v4/locales/*": {
|
|
75
90
|
"@zod/source": "./v4/locales/*",
|
|
91
|
+
"types": "./v4/locales/*",
|
|
76
92
|
"import": "./v4/locales/*",
|
|
77
93
|
"require": "./v4/locales/*"
|
|
78
94
|
}
|
|
@@ -90,12 +106,12 @@
|
|
|
90
106
|
}
|
|
91
107
|
},
|
|
92
108
|
"scripts": {
|
|
93
|
-
"clean": "rm -rf dist && git clean -qxdf .",
|
|
109
|
+
"clean": "rm -rf dist && git clean -qxdf . -e node_modules",
|
|
94
110
|
"build": "pnpm clean && zshy",
|
|
95
111
|
"postbuild": "pnpm biome check --write .",
|
|
96
112
|
"test:watch": "pnpm vitest",
|
|
97
113
|
"test": "pnpm vitest run",
|
|
98
|
-
"test:
|
|
114
|
+
"test:resolution": "pnpm build && pnpm attw --pack . && pnpm run --filter @zod/resolution test",
|
|
99
115
|
"bump:beta": "pnpm version \"v$(pnpm pkg get version | jq -r)-beta.$(date +%Y%m%dT%H%M%S)\"",
|
|
100
116
|
"pub:beta": "pnpm bump:beta && pnpm publish --tag next --publish-branch v4 --no-git-checks --dry-run"
|
|
101
117
|
}
|
package/v3/ZodError.cjs
CHANGED
|
@@ -117,8 +117,9 @@ class ZodError extends Error {
|
|
|
117
117
|
const formErrors = [];
|
|
118
118
|
for (const sub of this.issues) {
|
|
119
119
|
if (sub.path.length > 0) {
|
|
120
|
-
|
|
121
|
-
fieldErrors[
|
|
120
|
+
const firstEl = sub.path[0];
|
|
121
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
122
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
122
123
|
}
|
|
123
124
|
else {
|
|
124
125
|
formErrors.push(mapper(sub));
|
package/v3/ZodError.js
CHANGED
|
@@ -113,8 +113,9 @@ export class ZodError extends Error {
|
|
|
113
113
|
const formErrors = [];
|
|
114
114
|
for (const sub of this.issues) {
|
|
115
115
|
if (sub.path.length > 0) {
|
|
116
|
-
|
|
117
|
-
fieldErrors[
|
|
116
|
+
const firstEl = sub.path[0];
|
|
117
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
118
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
118
119
|
}
|
|
119
120
|
else {
|
|
120
121
|
formErrors.push(mapper(sub));
|
package/v3/types.cjs
CHANGED
package/v3/types.js
CHANGED
package/v4/core/schemas.cjs
CHANGED
|
@@ -262,7 +262,6 @@ exports.$ZodKSUID = core.$constructor("$ZodKSUID", (inst, def) => {
|
|
|
262
262
|
exports.$ZodISODateTime = core.$constructor("$ZodISODateTime", (inst, def) => {
|
|
263
263
|
def.pattern ?? (def.pattern = regexes.datetime(def));
|
|
264
264
|
exports.$ZodStringFormat.init(inst, def);
|
|
265
|
-
const _super = inst._zod.check;
|
|
266
265
|
});
|
|
267
266
|
exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
|
|
268
267
|
def.pattern ?? (def.pattern = regexes.date);
|
|
@@ -271,7 +270,6 @@ exports.$ZodISODate = core.$constructor("$ZodISODate", (inst, def) => {
|
|
|
271
270
|
exports.$ZodISOTime = core.$constructor("$ZodISOTime", (inst, def) => {
|
|
272
271
|
def.pattern ?? (def.pattern = regexes.time(def));
|
|
273
272
|
exports.$ZodStringFormat.init(inst, def);
|
|
274
|
-
const _super = inst._zod.check;
|
|
275
273
|
});
|
|
276
274
|
exports.$ZodISODuration = core.$constructor("$ZodISODuration", (inst, def) => {
|
|
277
275
|
def.pattern ?? (def.pattern = regexes.duration);
|
|
@@ -407,6 +405,8 @@ function isValidJWT(token, algorithm = null) {
|
|
|
407
405
|
if (tokensParts.length !== 3)
|
|
408
406
|
return false;
|
|
409
407
|
const [header] = tokensParts;
|
|
408
|
+
if (!header)
|
|
409
|
+
return false;
|
|
410
410
|
const parsedHeader = JSON.parse(atob(header));
|
|
411
411
|
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
412
412
|
return false;
|
package/v4/core/schemas.js
CHANGED
|
@@ -231,7 +231,6 @@ export const $ZodKSUID = /*@__PURE__*/ core.$constructor("$ZodKSUID", (inst, def
|
|
|
231
231
|
export const $ZodISODateTime = /*@__PURE__*/ core.$constructor("$ZodISODateTime", (inst, def) => {
|
|
232
232
|
def.pattern ?? (def.pattern = regexes.datetime(def));
|
|
233
233
|
$ZodStringFormat.init(inst, def);
|
|
234
|
-
const _super = inst._zod.check;
|
|
235
234
|
});
|
|
236
235
|
export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst, def) => {
|
|
237
236
|
def.pattern ?? (def.pattern = regexes.date);
|
|
@@ -240,7 +239,6 @@ export const $ZodISODate = /*@__PURE__*/ core.$constructor("$ZodISODate", (inst,
|
|
|
240
239
|
export const $ZodISOTime = /*@__PURE__*/ core.$constructor("$ZodISOTime", (inst, def) => {
|
|
241
240
|
def.pattern ?? (def.pattern = regexes.time(def));
|
|
242
241
|
$ZodStringFormat.init(inst, def);
|
|
243
|
-
const _super = inst._zod.check;
|
|
244
242
|
});
|
|
245
243
|
export const $ZodISODuration = /*@__PURE__*/ core.$constructor("$ZodISODuration", (inst, def) => {
|
|
246
244
|
def.pattern ?? (def.pattern = regexes.duration);
|
|
@@ -376,6 +374,8 @@ export function isValidJWT(token, algorithm = null) {
|
|
|
376
374
|
if (tokensParts.length !== 3)
|
|
377
375
|
return false;
|
|
378
376
|
const [header] = tokensParts;
|
|
377
|
+
if (!header)
|
|
378
|
+
return false;
|
|
379
379
|
const parsedHeader = JSON.parse(atob(header));
|
|
380
380
|
if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
|
|
381
381
|
return false;
|
package/v4/core/util.cjs
CHANGED
|
@@ -173,9 +173,6 @@ exports.allowsEval = cached(() => {
|
|
|
173
173
|
return false;
|
|
174
174
|
}
|
|
175
175
|
});
|
|
176
|
-
function _isObject(o) {
|
|
177
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
178
|
-
}
|
|
179
176
|
function isPlainObject(o) {
|
|
180
177
|
if (isObject(o) === false)
|
|
181
178
|
return false;
|
|
@@ -459,7 +456,7 @@ function required(Class, schema, mask) {
|
|
|
459
456
|
}
|
|
460
457
|
function aborted(x, startIndex = 0) {
|
|
461
458
|
for (let i = startIndex; i < x.issues.length; i++) {
|
|
462
|
-
if (x.issues[i]
|
|
459
|
+
if (x.issues[i]?.continue !== true)
|
|
463
460
|
return true;
|
|
464
461
|
}
|
|
465
462
|
return false;
|
package/v4/core/util.js
CHANGED
|
@@ -129,9 +129,6 @@ export const allowsEval = cached(() => {
|
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
|
-
function _isObject(o) {
|
|
133
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
134
|
-
}
|
|
135
132
|
export function isPlainObject(o) {
|
|
136
133
|
if (isObject(o) === false)
|
|
137
134
|
return false;
|
|
@@ -414,7 +411,7 @@ export function required(Class, schema, mask) {
|
|
|
414
411
|
}
|
|
415
412
|
export function aborted(x, startIndex = 0) {
|
|
416
413
|
for (let i = startIndex; i < x.issues.length; i++) {
|
|
417
|
-
if (x.issues[i]
|
|
414
|
+
if (x.issues[i]?.continue !== true)
|
|
418
415
|
return true;
|
|
419
416
|
}
|
|
420
417
|
return false;
|