@exodus/zod 3.24.1-rc.3 → 3.24.1-rc.5
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/LICENSE +1 -1
- package/lib/index.mjs +17 -16
- package/package.json +5 -14
package/LICENSE
CHANGED
package/lib/index.mjs
CHANGED
|
@@ -49,6 +49,7 @@ var objectUtil;
|
|
|
49
49
|
(function (objectUtil) {
|
|
50
50
|
objectUtil.mergeShapes = (first, second) => {
|
|
51
51
|
return {
|
|
52
|
+
__proto__: null,
|
|
52
53
|
...first,
|
|
53
54
|
...second, // second overwrites first
|
|
54
55
|
};
|
|
@@ -235,7 +236,7 @@ class ZodError extends Error {
|
|
|
235
236
|
this.issues = [...this.issues, ...subs];
|
|
236
237
|
};
|
|
237
238
|
flatten(mapper = (issue) => issue.message) {
|
|
238
|
-
const fieldErrors =
|
|
239
|
+
const fieldErrors = Object.create(null);
|
|
239
240
|
const formErrors = [];
|
|
240
241
|
for (const sub of this.issues) {
|
|
241
242
|
if (sub.path.length > 0) {
|
|
@@ -464,7 +465,7 @@ class ParseStatus {
|
|
|
464
465
|
return ParseStatus.mergeObjectSync(status, syncPairs);
|
|
465
466
|
}
|
|
466
467
|
static mergeObjectSync(status, pairs) {
|
|
467
|
-
const finalObject =
|
|
468
|
+
const finalObject = Object.create(null);
|
|
468
469
|
for (const pair of pairs) {
|
|
469
470
|
const { key, value } = pair;
|
|
470
471
|
if (key.status === "aborted")
|
|
@@ -475,7 +476,7 @@ class ParseStatus {
|
|
|
475
476
|
status.dirty();
|
|
476
477
|
if (value.status === "dirty")
|
|
477
478
|
status.dirty();
|
|
478
|
-
if (key.value
|
|
479
|
+
if (!(key.value in Object.prototype) &&
|
|
479
480
|
(typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
480
481
|
finalObject[key.value] = value.value;
|
|
481
482
|
}
|
|
@@ -545,7 +546,7 @@ const handleResult = (ctx, result) => {
|
|
|
545
546
|
};
|
|
546
547
|
function processCreateParams(params) {
|
|
547
548
|
if (!params)
|
|
548
|
-
return
|
|
549
|
+
return Object.create(null);
|
|
549
550
|
const { errorMap, invalid_type_error, required_error, description } = params;
|
|
550
551
|
if (errorMap && (invalid_type_error || required_error)) {
|
|
551
552
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
@@ -2351,7 +2352,7 @@ class ZodArray extends ZodType {
|
|
|
2351
2352
|
}
|
|
2352
2353
|
function deepPartialify(schema) {
|
|
2353
2354
|
if (schema instanceof ZodObject) {
|
|
2354
|
-
const newShape =
|
|
2355
|
+
const newShape = Object.create(null);
|
|
2355
2356
|
for (const key in schema.shape) {
|
|
2356
2357
|
const fieldSchema = schema.shape[key];
|
|
2357
2358
|
newShape[key] = ZodOptional.create(deepPartialify(fieldSchema));
|
|
@@ -2502,7 +2503,7 @@ class ZodObject extends ZodType {
|
|
|
2502
2503
|
};
|
|
2503
2504
|
},
|
|
2504
2505
|
}
|
|
2505
|
-
:
|
|
2506
|
+
: Object.create(null)),
|
|
2506
2507
|
});
|
|
2507
2508
|
}
|
|
2508
2509
|
strip() {
|
|
@@ -2638,7 +2639,7 @@ class ZodObject extends ZodType {
|
|
|
2638
2639
|
// return merged;
|
|
2639
2640
|
// }
|
|
2640
2641
|
setKey(key, schema) {
|
|
2641
|
-
return this.augment({ [key]: schema });
|
|
2642
|
+
return this.augment(Object.assign(Object.create(null), { [key]: schema }));
|
|
2642
2643
|
}
|
|
2643
2644
|
// merge<Incoming extends AnyZodObject>(
|
|
2644
2645
|
// merging: Incoming
|
|
@@ -2668,7 +2669,7 @@ class ZodObject extends ZodType {
|
|
|
2668
2669
|
});
|
|
2669
2670
|
}
|
|
2670
2671
|
pick(mask) {
|
|
2671
|
-
const shape =
|
|
2672
|
+
const shape = Object.create(null);
|
|
2672
2673
|
util.objectKeys(mask).forEach((key) => {
|
|
2673
2674
|
if (mask[key] && this.shape[key]) {
|
|
2674
2675
|
shape[key] = this.shape[key];
|
|
@@ -2680,7 +2681,7 @@ class ZodObject extends ZodType {
|
|
|
2680
2681
|
});
|
|
2681
2682
|
}
|
|
2682
2683
|
omit(mask) {
|
|
2683
|
-
const shape =
|
|
2684
|
+
const shape = Object.create(null);
|
|
2684
2685
|
util.objectKeys(this.shape).forEach((key) => {
|
|
2685
2686
|
if (!mask[key]) {
|
|
2686
2687
|
shape[key] = this.shape[key];
|
|
@@ -2698,7 +2699,7 @@ class ZodObject extends ZodType {
|
|
|
2698
2699
|
return deepPartialify(this);
|
|
2699
2700
|
}
|
|
2700
2701
|
partial(mask) {
|
|
2701
|
-
const newShape =
|
|
2702
|
+
const newShape = Object.create(null);
|
|
2702
2703
|
util.objectKeys(this.shape).forEach((key) => {
|
|
2703
2704
|
const fieldSchema = this.shape[key];
|
|
2704
2705
|
if (mask && !mask[key]) {
|
|
@@ -2714,7 +2715,7 @@ class ZodObject extends ZodType {
|
|
|
2714
2715
|
});
|
|
2715
2716
|
}
|
|
2716
2717
|
required(mask) {
|
|
2717
|
-
const newShape =
|
|
2718
|
+
const newShape = Object.create(null);
|
|
2718
2719
|
util.objectKeys(this.shape).forEach((key) => {
|
|
2719
2720
|
if (mask && !mask[key]) {
|
|
2720
2721
|
newShape[key] = this.shape[key];
|
|
@@ -3002,7 +3003,7 @@ function mergeValues(a, b) {
|
|
|
3002
3003
|
const sharedKeys = util
|
|
3003
3004
|
.objectKeys(a)
|
|
3004
3005
|
.filter((key) => bKeys.indexOf(key) !== -1);
|
|
3005
|
-
const newObj = { ...a, ...b };
|
|
3006
|
+
const newObj = { __proto__: null, ...a, ...b };
|
|
3006
3007
|
for (const key of sharedKeys) {
|
|
3007
3008
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
3008
3009
|
if (!sharedValue.valid) {
|
|
@@ -3573,21 +3574,21 @@ class ZodEnum extends ZodType {
|
|
|
3573
3574
|
return this._def.values;
|
|
3574
3575
|
}
|
|
3575
3576
|
get enum() {
|
|
3576
|
-
const enumValues =
|
|
3577
|
+
const enumValues = Object.create(null);
|
|
3577
3578
|
for (const val of this._def.values) {
|
|
3578
3579
|
enumValues[val] = val;
|
|
3579
3580
|
}
|
|
3580
3581
|
return enumValues;
|
|
3581
3582
|
}
|
|
3582
3583
|
get Values() {
|
|
3583
|
-
const enumValues =
|
|
3584
|
+
const enumValues = Object.create(null);
|
|
3584
3585
|
for (const val of this._def.values) {
|
|
3585
3586
|
enumValues[val] = val;
|
|
3586
3587
|
}
|
|
3587
3588
|
return enumValues;
|
|
3588
3589
|
}
|
|
3589
3590
|
get Enum() {
|
|
3590
|
-
const enumValues =
|
|
3591
|
+
const enumValues = Object.create(null);
|
|
3591
3592
|
for (const val of this._def.values) {
|
|
3592
3593
|
enumValues[val] = val;
|
|
3593
3594
|
}
|
|
@@ -4069,7 +4070,7 @@ class ZodReadonly extends ZodType {
|
|
|
4069
4070
|
return this._def.innerType;
|
|
4070
4071
|
}
|
|
4071
4072
|
}
|
|
4072
|
-
function custom(check, params =
|
|
4073
|
+
function custom(check, params = Object.create(null),
|
|
4073
4074
|
/**
|
|
4074
4075
|
* @deprecated
|
|
4075
4076
|
*
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/zod",
|
|
3
|
-
"version": "3.24.1-rc.
|
|
4
|
-
"author": "
|
|
3
|
+
"version": "3.24.1-rc.5",
|
|
4
|
+
"author": "Exodus Movement, Inc.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/ExodusMovement/zod.git"
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"module": "./lib/index.mjs",
|
|
@@ -23,8 +23,6 @@
|
|
|
23
23
|
"@typescript-eslint/eslint-plugin": "^5.15.0",
|
|
24
24
|
"@typescript-eslint/parser": "^5.15.0",
|
|
25
25
|
"babel-jest": "^29.5.0",
|
|
26
|
-
"benchmark": "^2.1.4",
|
|
27
|
-
"dependency-cruiser": "^9.19.0",
|
|
28
26
|
"eslint": "^8.11.0",
|
|
29
27
|
"eslint-config-prettier": "^8.5.0",
|
|
30
28
|
"eslint-plugin-ban": "^1.6.0",
|
|
@@ -55,7 +53,7 @@
|
|
|
55
53
|
"./package.json": "./package.json"
|
|
56
54
|
},
|
|
57
55
|
"bugs": {
|
|
58
|
-
"url": "https://github.com/
|
|
56
|
+
"url": "https://github.com/ExodusMovement/zod/issues"
|
|
59
57
|
},
|
|
60
58
|
"description": "TypeScript-first schema declaration and validation library with static type inference",
|
|
61
59
|
"files": [
|
|
@@ -63,8 +61,6 @@
|
|
|
63
61
|
"/index.d.ts",
|
|
64
62
|
"!/lib/benchmarks"
|
|
65
63
|
],
|
|
66
|
-
"funding": "https://github.com/sponsors/colinhacks",
|
|
67
|
-
"homepage": "https://zod.dev",
|
|
68
64
|
"keywords": [
|
|
69
65
|
"typescript",
|
|
70
66
|
"schema",
|
|
@@ -101,12 +97,7 @@
|
|
|
101
97
|
"test:vitest": "npx vitest --config ./configs/vitest.config.ts",
|
|
102
98
|
"test:ts-jest": "npx jest --config ./configs/ts-jest.config.json",
|
|
103
99
|
"test:swc": "npx jest --config ./configs/swc-jest.config.json",
|
|
104
|
-
"prepublishOnly": "npm run test && npm run build"
|
|
105
|
-
"play": "nodemon -e ts -w . -x tsx playground.ts",
|
|
106
|
-
"depcruise": "depcruise -c .dependency-cruiser.js src",
|
|
107
|
-
"benchmark": "tsx src/benchmarks/index.ts",
|
|
108
|
-
"prepare": "husky install",
|
|
109
|
-
"docs": "netlify dev"
|
|
100
|
+
"prepublishOnly": "npm run test && npm run build"
|
|
110
101
|
},
|
|
111
102
|
"sideEffects": false,
|
|
112
103
|
"support": {
|