zod 3.25.30 → 3.25.31
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/cjs/v4/core/api.js
CHANGED
|
@@ -940,9 +940,9 @@ function _refine(Class, fn, _params = {}) {
|
|
|
940
940
|
return _custom(Class, fn, _params);
|
|
941
941
|
}
|
|
942
942
|
function _stringbool(Classes, _params) {
|
|
943
|
-
const
|
|
944
|
-
const trueValues = new Set(
|
|
945
|
-
const falseValues = new Set(
|
|
943
|
+
const { case: _case, error, truthy, falsy } = util.normalizeParams(_params);
|
|
944
|
+
const trueValues = new Set(truthy ?? ["true", "1", "yes", "on", "y", "enabled"]);
|
|
945
|
+
const falseValues = new Set(falsy ?? ["false", "0", "no", "off", "n", "disabled"]);
|
|
946
946
|
const _Pipe = Classes.Pipe ?? schemas.$ZodPipe;
|
|
947
947
|
const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;
|
|
948
948
|
const _Unknown = Classes.Unknown ?? schemas.$ZodUnknown;
|
|
@@ -954,7 +954,7 @@ function _stringbool(Classes, _params) {
|
|
|
954
954
|
check: (ctx) => {
|
|
955
955
|
if (typeof ctx.value === "string") {
|
|
956
956
|
let data = ctx.value;
|
|
957
|
-
if (
|
|
957
|
+
if (_case !== "sensitive")
|
|
958
958
|
data = data.toLowerCase();
|
|
959
959
|
if (trueValues.has(data)) {
|
|
960
960
|
ctx.value = true;
|
|
@@ -987,12 +987,15 @@ function _stringbool(Classes, _params) {
|
|
|
987
987
|
},
|
|
988
988
|
},
|
|
989
989
|
],
|
|
990
|
+
error,
|
|
990
991
|
});
|
|
991
992
|
return new _Pipe({
|
|
992
993
|
type: "pipe",
|
|
993
994
|
in: inst,
|
|
994
995
|
out: new _Boolean({
|
|
995
996
|
type: "boolean",
|
|
997
|
+
error,
|
|
996
998
|
}),
|
|
999
|
+
error,
|
|
997
1000
|
});
|
|
998
1001
|
}
|
package/dist/cjs/v4/core/util.js
CHANGED
|
@@ -156,7 +156,7 @@ function esc(str) {
|
|
|
156
156
|
return JSON.stringify(str);
|
|
157
157
|
}
|
|
158
158
|
function isObject(data) {
|
|
159
|
-
return typeof data === "object" && data !== null;
|
|
159
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
160
160
|
}
|
|
161
161
|
exports.allowsEval = cached(() => {
|
|
162
162
|
try {
|
package/dist/esm/v4/core/api.js
CHANGED
|
@@ -809,9 +809,9 @@ export function _refine(Class, fn, _params = {}) {
|
|
|
809
809
|
return _custom(Class, fn, _params);
|
|
810
810
|
}
|
|
811
811
|
export function _stringbool(Classes, _params) {
|
|
812
|
-
const
|
|
813
|
-
const trueValues = new Set(
|
|
814
|
-
const falseValues = new Set(
|
|
812
|
+
const { case: _case, error, truthy, falsy } = util.normalizeParams(_params);
|
|
813
|
+
const trueValues = new Set(truthy ?? ["true", "1", "yes", "on", "y", "enabled"]);
|
|
814
|
+
const falseValues = new Set(falsy ?? ["false", "0", "no", "off", "n", "disabled"]);
|
|
815
815
|
const _Pipe = Classes.Pipe ?? schemas.$ZodPipe;
|
|
816
816
|
const _Boolean = Classes.Boolean ?? schemas.$ZodBoolean;
|
|
817
817
|
const _Unknown = Classes.Unknown ?? schemas.$ZodUnknown;
|
|
@@ -823,7 +823,7 @@ export function _stringbool(Classes, _params) {
|
|
|
823
823
|
check: (ctx) => {
|
|
824
824
|
if (typeof ctx.value === "string") {
|
|
825
825
|
let data = ctx.value;
|
|
826
|
-
if (
|
|
826
|
+
if (_case !== "sensitive")
|
|
827
827
|
data = data.toLowerCase();
|
|
828
828
|
if (trueValues.has(data)) {
|
|
829
829
|
ctx.value = true;
|
|
@@ -856,12 +856,15 @@ export function _stringbool(Classes, _params) {
|
|
|
856
856
|
},
|
|
857
857
|
},
|
|
858
858
|
],
|
|
859
|
+
error,
|
|
859
860
|
});
|
|
860
861
|
return new _Pipe({
|
|
861
862
|
type: "pipe",
|
|
862
863
|
in: inst,
|
|
863
864
|
out: new _Boolean({
|
|
864
865
|
type: "boolean",
|
|
866
|
+
error,
|
|
865
867
|
}),
|
|
868
|
+
error,
|
|
866
869
|
});
|
|
867
870
|
}
|
package/dist/esm/v4/core/util.js
CHANGED
|
@@ -112,7 +112,7 @@ export function esc(str) {
|
|
|
112
112
|
return JSON.stringify(str);
|
|
113
113
|
}
|
|
114
114
|
export function isObject(data) {
|
|
115
|
-
return typeof data === "object" && data !== null;
|
|
115
|
+
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
116
116
|
}
|
|
117
117
|
export const allowsEval = cached(() => {
|
|
118
118
|
try {
|
|
@@ -422,10 +422,13 @@ out Shape extends core.$ZodShape = core.$ZodLooseShape, out Config extends core.
|
|
|
422
422
|
strip(): ZodObject<Shape, core.$strict>;
|
|
423
423
|
extend<U extends core.$ZodLooseShape & Partial<Record<keyof Shape, core.$ZodType>>>(shape: U): ZodObject<util.Extend<Shape, U>, Config>;
|
|
424
424
|
/**
|
|
425
|
-
* @deprecated Use
|
|
425
|
+
* @deprecated Use spread syntax and the `.shape` property to combine two object schemas:
|
|
426
426
|
*
|
|
427
427
|
* ```ts
|
|
428
|
-
* z.object({
|
|
428
|
+
* const A = z.object({ a: z.string() });
|
|
429
|
+
* const B = z.object({ b: z.number() });
|
|
430
|
+
*
|
|
431
|
+
* const C = z.object({
|
|
429
432
|
* ...A.shape,
|
|
430
433
|
* ...B.shape
|
|
431
434
|
* });
|
package/package.json
CHANGED