zod 4.3.4 → 4.3.6
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/mini/index.cjs +16 -1
- package/mini/index.d.cts +3 -1
- package/mini/index.d.ts +3 -1
- package/mini/index.js +3 -1
- package/package.json +1 -1
- package/src/mini/index.ts +3 -1
- package/src/v4/classic/tests/codec.test.ts +1 -1
- package/src/v4/classic/tests/record.test.ts +32 -0
- package/src/v4/classic/tests/to-json-schema.test.ts +15 -0
- package/src/v4/core/schemas.ts +3 -8
- package/src/v4/core/to-json-schema.ts +2 -2
- package/src/v4/core/versions.ts +1 -1
- package/src/v4/mini/schemas.ts +1 -1
- package/src/v4-mini/index.ts +3 -1
- package/v4/core/schemas.cjs +3 -5
- package/v4/core/schemas.js +3 -5
- package/v4/core/to-json-schema.cjs +1 -1
- package/v4/core/to-json-schema.js +1 -1
- package/v4/core/versions.cjs +1 -1
- package/v4/core/versions.js +1 -1
- package/v4/mini/schemas.cjs +31 -31
- package/v4/mini/schemas.d.cts +1 -1
- package/v4/mini/schemas.d.ts +1 -1
- package/v4/mini/schemas.js +1 -1
- package/v4-mini/index.cjs +16 -1
- package/v4-mini/index.d.cts +3 -1
- package/v4-mini/index.d.ts +3 -1
- package/v4-mini/index.js +3 -1
package/mini/index.cjs
CHANGED
|
@@ -10,8 +10,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
29
|
+
exports.z = void 0;
|
|
30
|
+
const z = __importStar(require("../v4/mini/external.cjs"));
|
|
31
|
+
exports.z = z;
|
|
32
|
+
__exportStar(require("../v4/mini/external.cjs"), exports);
|
package/mini/index.d.cts
CHANGED
package/mini/index.d.ts
CHANGED
package/mini/index.js
CHANGED
package/package.json
CHANGED
package/src/mini/index.ts
CHANGED
|
@@ -503,7 +503,7 @@ test("codec type enforcement - complex types", () => {
|
|
|
503
503
|
);
|
|
504
504
|
});
|
|
505
505
|
|
|
506
|
-
test("
|
|
506
|
+
test("codec with overwrites", () => {
|
|
507
507
|
const stringPlusA = z.string().overwrite((val) => val + "a");
|
|
508
508
|
const A = z
|
|
509
509
|
.codec(stringPlusA, stringPlusA, {
|
|
@@ -487,6 +487,38 @@ test("partialRecord with z.literal([key, ...])", () => {
|
|
|
487
487
|
`);
|
|
488
488
|
});
|
|
489
489
|
|
|
490
|
+
test("partialRecord with numeric literal keys", () => {
|
|
491
|
+
const Keys = z.literal([1, 2, 3]);
|
|
492
|
+
const schema = z.partialRecord(Keys, z.string());
|
|
493
|
+
type Schema = z.infer<typeof schema>;
|
|
494
|
+
expectTypeOf<Schema>().toEqualTypeOf<Partial<Record<1 | 2 | 3, string>>>();
|
|
495
|
+
|
|
496
|
+
// Should parse valid partials with numeric keys (as strings in JS objects)
|
|
497
|
+
expect(schema.parse({})).toEqual({});
|
|
498
|
+
expect(schema.parse({ 1: "one" })).toEqual({ 1: "one" });
|
|
499
|
+
expect(schema.parse({ 2: "two", 3: "three" })).toEqual({ 2: "two", 3: "three" });
|
|
500
|
+
|
|
501
|
+
// Should fail with unrecognized key
|
|
502
|
+
expect(schema.safeParse({ 4: "four" }).success).toBe(false);
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
test("partialRecord with union of string and numeric literal keys", () => {
|
|
506
|
+
const StringKeys = z.literal(["a", "b", "c"]);
|
|
507
|
+
const NumericKeys = z.literal([1, 2, 3]);
|
|
508
|
+
const schema = z.partialRecord(z.union([StringKeys, NumericKeys]), z.string());
|
|
509
|
+
type Schema = z.infer<typeof schema>;
|
|
510
|
+
expectTypeOf<Schema>().toEqualTypeOf<Partial<Record<"a" | "b" | "c" | 1 | 2 | 3, string>>>();
|
|
511
|
+
|
|
512
|
+
// Should parse valid partials with mixed keys
|
|
513
|
+
expect(schema.parse({})).toEqual({});
|
|
514
|
+
expect(schema.parse({ a: "1", 2: "4" })).toEqual({ a: "1", 2: "4" });
|
|
515
|
+
expect(schema.parse({ a: "a", b: "b", 1: "1", 2: "2" })).toEqual({ a: "a", b: "b", 1: "1", 2: "2" });
|
|
516
|
+
|
|
517
|
+
// Should fail with unrecognized key
|
|
518
|
+
expect(schema.safeParse({ d: "d" }).success).toBe(false);
|
|
519
|
+
expect(schema.safeParse({ 4: "4" }).success).toBe(false);
|
|
520
|
+
});
|
|
521
|
+
|
|
490
522
|
test("looseRecord passes through non-matching keys", () => {
|
|
491
523
|
const schema = z.looseRecord(z.string().regex(/^S_/), z.string());
|
|
492
524
|
|
|
@@ -2491,6 +2491,21 @@ test("_ref", () => {
|
|
|
2491
2491
|
"type": "string",
|
|
2492
2492
|
}
|
|
2493
2493
|
`);
|
|
2494
|
+
|
|
2495
|
+
const d = z.toJSONSchema(z.string().meta({ id: "foo" }).describe("bar").optional());
|
|
2496
|
+
expect(d).toMatchInlineSnapshot(`
|
|
2497
|
+
{
|
|
2498
|
+
"$defs": {
|
|
2499
|
+
"foo": {
|
|
2500
|
+
"id": "foo",
|
|
2501
|
+
"type": "string",
|
|
2502
|
+
},
|
|
2503
|
+
},
|
|
2504
|
+
"$ref": "#/$defs/foo",
|
|
2505
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
2506
|
+
"description": "bar",
|
|
2507
|
+
}
|
|
2508
|
+
`);
|
|
2494
2509
|
});
|
|
2495
2510
|
|
|
2496
2511
|
test("defaults/prefaults", () => {
|
package/src/v4/core/schemas.ts
CHANGED
|
@@ -2804,14 +2804,9 @@ export const $ZodRecord: core.$constructor<$ZodRecord> = /*@__PURE__*/ core.$con
|
|
|
2804
2804
|
throw new Error("Async schemas not supported in object keys currently");
|
|
2805
2805
|
}
|
|
2806
2806
|
|
|
2807
|
-
// Numeric string fallback: if key
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
regexes.number.test(key) &&
|
|
2811
|
-
keyResult.issues.length &&
|
|
2812
|
-
keyResult.issues.some(
|
|
2813
|
-
(iss) => iss.code === "invalid_type" && (iss as errors.$ZodIssueInvalidType).expected === "number"
|
|
2814
|
-
);
|
|
2807
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
2808
|
+
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
2809
|
+
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
2815
2810
|
if (checkNumericKey) {
|
|
2816
2811
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
2817
2812
|
if (retryResult instanceof Promise) {
|
|
@@ -406,10 +406,10 @@ export function finalize<T extends schemas.$ZodType>(
|
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
// When ref was extracted to $defs, remove properties that match the definition
|
|
409
|
-
if (refSchema.$ref) {
|
|
409
|
+
if (refSchema.$ref && refSeen.def) {
|
|
410
410
|
for (const key in schema) {
|
|
411
411
|
if (key === "$ref" || key === "allOf") continue;
|
|
412
|
-
if (key in refSeen.def
|
|
412
|
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
|
|
413
413
|
delete schema[key];
|
|
414
414
|
}
|
|
415
415
|
}
|
package/src/v4/core/versions.ts
CHANGED
package/src/v4/mini/schemas.ts
CHANGED
package/src/v4-mini/index.ts
CHANGED
package/v4/core/schemas.cjs
CHANGED
|
@@ -1396,11 +1396,9 @@ exports.$ZodRecord = core.$constructor("$ZodRecord", (inst, def) => {
|
|
|
1396
1396
|
if (keyResult instanceof Promise) {
|
|
1397
1397
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1398
1398
|
}
|
|
1399
|
-
// Numeric string fallback: if key
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
keyResult.issues.length &&
|
|
1403
|
-
keyResult.issues.some((iss) => iss.code === "invalid_type" && iss.expected === "number");
|
|
1399
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
1400
|
+
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1401
|
+
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
1404
1402
|
if (checkNumericKey) {
|
|
1405
1403
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
1406
1404
|
if (retryResult instanceof Promise) {
|
package/v4/core/schemas.js
CHANGED
|
@@ -1365,11 +1365,9 @@ export const $ZodRecord = /*@__PURE__*/ core.$constructor("$ZodRecord", (inst, d
|
|
|
1365
1365
|
if (keyResult instanceof Promise) {
|
|
1366
1366
|
throw new Error("Async schemas not supported in object keys currently");
|
|
1367
1367
|
}
|
|
1368
|
-
// Numeric string fallback: if key
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
keyResult.issues.length &&
|
|
1372
|
-
keyResult.issues.some((iss) => iss.code === "invalid_type" && iss.expected === "number");
|
|
1368
|
+
// Numeric string fallback: if key is a numeric string and failed, retry with Number(key)
|
|
1369
|
+
// This handles z.number(), z.literal([1, 2, 3]), and unions containing numeric literals
|
|
1370
|
+
const checkNumericKey = typeof key === "string" && regexes.number.test(key) && keyResult.issues.length;
|
|
1373
1371
|
if (checkNumericKey) {
|
|
1374
1372
|
const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
|
|
1375
1373
|
if (retryResult instanceof Promise) {
|
|
@@ -260,7 +260,7 @@ function finalize(ctx, schema) {
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
// When ref was extracted to $defs, remove properties that match the definition
|
|
263
|
-
if (refSchema.$ref) {
|
|
263
|
+
if (refSchema.$ref && refSeen.def) {
|
|
264
264
|
for (const key in schema) {
|
|
265
265
|
if (key === "$ref" || key === "allOf")
|
|
266
266
|
continue;
|
|
@@ -253,7 +253,7 @@ export function finalize(ctx, schema) {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
// When ref was extracted to $defs, remove properties that match the definition
|
|
256
|
-
if (refSchema.$ref) {
|
|
256
|
+
if (refSchema.$ref && refSeen.def) {
|
|
257
257
|
for (const key in schema) {
|
|
258
258
|
if (key === "$ref" || key === "allOf")
|
|
259
259
|
continue;
|
package/v4/core/versions.cjs
CHANGED
package/v4/core/versions.js
CHANGED
package/v4/mini/schemas.cjs
CHANGED
|
@@ -127,7 +127,7 @@ exports.function = _function;
|
|
|
127
127
|
exports._function = _function;
|
|
128
128
|
exports.function = _function;
|
|
129
129
|
const core = __importStar(require("../core/index.cjs"));
|
|
130
|
-
const
|
|
130
|
+
const util = __importStar(require("../core/util.cjs"));
|
|
131
131
|
const parse = __importStar(require("./parse.cjs"));
|
|
132
132
|
exports.ZodMiniType = core.$constructor("ZodMiniType", (inst, def) => {
|
|
133
133
|
if (!inst._zod)
|
|
@@ -220,7 +220,7 @@ function httpUrl(params) {
|
|
|
220
220
|
return core._url(exports.ZodMiniURL, {
|
|
221
221
|
protocol: /^https?$/,
|
|
222
222
|
hostname: core.regexes.domain,
|
|
223
|
-
...
|
|
223
|
+
...util.normalizeParams(params),
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
exports.ZodMiniEmoji = core.$constructor("ZodMiniEmoji", (inst, def) => {
|
|
@@ -517,7 +517,7 @@ function array(element, params) {
|
|
|
517
517
|
return new exports.ZodMiniArray({
|
|
518
518
|
type: "array",
|
|
519
519
|
element: element,
|
|
520
|
-
...
|
|
520
|
+
...util.normalizeParams(params),
|
|
521
521
|
});
|
|
522
522
|
}
|
|
523
523
|
// .keyof
|
|
@@ -529,14 +529,14 @@ function keyof(schema) {
|
|
|
529
529
|
exports.ZodMiniObject = core.$constructor("ZodMiniObject", (inst, def) => {
|
|
530
530
|
core.$ZodObject.init(inst, def);
|
|
531
531
|
exports.ZodMiniType.init(inst, def);
|
|
532
|
-
|
|
532
|
+
util.defineLazy(inst, "shape", () => def.shape);
|
|
533
533
|
});
|
|
534
534
|
// @__NO_SIDE_EFFECTS__
|
|
535
535
|
function object(shape, params) {
|
|
536
536
|
const def = {
|
|
537
537
|
type: "object",
|
|
538
538
|
shape: shape ?? {},
|
|
539
|
-
...
|
|
539
|
+
...util.normalizeParams(params),
|
|
540
540
|
};
|
|
541
541
|
return new exports.ZodMiniObject(def);
|
|
542
542
|
}
|
|
@@ -547,7 +547,7 @@ function strictObject(shape, params) {
|
|
|
547
547
|
type: "object",
|
|
548
548
|
shape,
|
|
549
549
|
catchall: never(),
|
|
550
|
-
...
|
|
550
|
+
...util.normalizeParams(params),
|
|
551
551
|
});
|
|
552
552
|
}
|
|
553
553
|
// looseObject
|
|
@@ -557,38 +557,38 @@ function looseObject(shape, params) {
|
|
|
557
557
|
type: "object",
|
|
558
558
|
shape,
|
|
559
559
|
catchall: unknown(),
|
|
560
|
-
...
|
|
560
|
+
...util.normalizeParams(params),
|
|
561
561
|
});
|
|
562
562
|
}
|
|
563
563
|
// object methods
|
|
564
564
|
// @__NO_SIDE_EFFECTS__
|
|
565
565
|
function extend(schema, shape) {
|
|
566
|
-
return
|
|
566
|
+
return util.extend(schema, shape);
|
|
567
567
|
}
|
|
568
568
|
// @__NO_SIDE_EFFECTS__
|
|
569
569
|
function safeExtend(schema, shape) {
|
|
570
|
-
return
|
|
570
|
+
return util.safeExtend(schema, shape);
|
|
571
571
|
}
|
|
572
572
|
// @__NO_SIDE_EFFECTS__
|
|
573
573
|
function merge(schema, shape) {
|
|
574
|
-
return
|
|
574
|
+
return util.extend(schema, shape);
|
|
575
575
|
}
|
|
576
576
|
// @__NO_SIDE_EFFECTS__
|
|
577
577
|
function pick(schema, mask) {
|
|
578
|
-
return
|
|
578
|
+
return util.pick(schema, mask);
|
|
579
579
|
}
|
|
580
580
|
// .omit
|
|
581
581
|
// @__NO_SIDE_EFFECTS__
|
|
582
582
|
function omit(schema, mask) {
|
|
583
|
-
return
|
|
583
|
+
return util.omit(schema, mask);
|
|
584
584
|
}
|
|
585
585
|
// @__NO_SIDE_EFFECTS__
|
|
586
586
|
function partial(schema, mask) {
|
|
587
|
-
return
|
|
587
|
+
return util.partial(exports.ZodMiniOptional, schema, mask);
|
|
588
588
|
}
|
|
589
589
|
// @__NO_SIDE_EFFECTS__
|
|
590
590
|
function required(schema, mask) {
|
|
591
|
-
return
|
|
591
|
+
return util.required(exports.ZodMiniNonOptional, schema, mask);
|
|
592
592
|
}
|
|
593
593
|
// @__NO_SIDE_EFFECTS__
|
|
594
594
|
function catchall(inst, catchall) {
|
|
@@ -603,7 +603,7 @@ function union(options, params) {
|
|
|
603
603
|
return new exports.ZodMiniUnion({
|
|
604
604
|
type: "union",
|
|
605
605
|
options: options,
|
|
606
|
-
...
|
|
606
|
+
...util.normalizeParams(params),
|
|
607
607
|
});
|
|
608
608
|
}
|
|
609
609
|
exports.ZodMiniXor = core.$constructor("ZodMiniXor", (inst, def) => {
|
|
@@ -618,7 +618,7 @@ function xor(options, params) {
|
|
|
618
618
|
type: "union",
|
|
619
619
|
options: options,
|
|
620
620
|
inclusive: false,
|
|
621
|
-
...
|
|
621
|
+
...util.normalizeParams(params),
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
exports.ZodMiniDiscriminatedUnion = core.$constructor("ZodMiniDiscriminatedUnion", (inst, def) => {
|
|
@@ -631,7 +631,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
631
631
|
type: "union",
|
|
632
632
|
options,
|
|
633
633
|
discriminator,
|
|
634
|
-
...
|
|
634
|
+
...util.normalizeParams(params),
|
|
635
635
|
});
|
|
636
636
|
}
|
|
637
637
|
exports.ZodMiniIntersection = core.$constructor("ZodMiniIntersection", (inst, def) => {
|
|
@@ -659,7 +659,7 @@ function tuple(items, _paramsOrRest, _params) {
|
|
|
659
659
|
type: "tuple",
|
|
660
660
|
items: items,
|
|
661
661
|
rest,
|
|
662
|
-
...
|
|
662
|
+
...util.normalizeParams(params),
|
|
663
663
|
});
|
|
664
664
|
}
|
|
665
665
|
exports.ZodMiniRecord = core.$constructor("ZodMiniRecord", (inst, def) => {
|
|
@@ -672,7 +672,7 @@ function record(keyType, valueType, params) {
|
|
|
672
672
|
type: "record",
|
|
673
673
|
keyType,
|
|
674
674
|
valueType: valueType,
|
|
675
|
-
...
|
|
675
|
+
...util.normalizeParams(params),
|
|
676
676
|
});
|
|
677
677
|
}
|
|
678
678
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -683,7 +683,7 @@ function partialRecord(keyType, valueType, params) {
|
|
|
683
683
|
type: "record",
|
|
684
684
|
keyType: k,
|
|
685
685
|
valueType: valueType,
|
|
686
|
-
...
|
|
686
|
+
...util.normalizeParams(params),
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
689
|
function looseRecord(keyType, valueType, params) {
|
|
@@ -692,7 +692,7 @@ function looseRecord(keyType, valueType, params) {
|
|
|
692
692
|
keyType,
|
|
693
693
|
valueType: valueType,
|
|
694
694
|
mode: "loose",
|
|
695
|
-
...
|
|
695
|
+
...util.normalizeParams(params),
|
|
696
696
|
});
|
|
697
697
|
}
|
|
698
698
|
exports.ZodMiniMap = core.$constructor("ZodMiniMap", (inst, def) => {
|
|
@@ -705,7 +705,7 @@ function map(keyType, valueType, params) {
|
|
|
705
705
|
type: "map",
|
|
706
706
|
keyType: keyType,
|
|
707
707
|
valueType: valueType,
|
|
708
|
-
...
|
|
708
|
+
...util.normalizeParams(params),
|
|
709
709
|
});
|
|
710
710
|
}
|
|
711
711
|
exports.ZodMiniSet = core.$constructor("ZodMiniSet", (inst, def) => {
|
|
@@ -717,7 +717,7 @@ function set(valueType, params) {
|
|
|
717
717
|
return new exports.ZodMiniSet({
|
|
718
718
|
type: "set",
|
|
719
719
|
valueType: valueType,
|
|
720
|
-
...
|
|
720
|
+
...util.normalizeParams(params),
|
|
721
721
|
});
|
|
722
722
|
}
|
|
723
723
|
exports.ZodMiniEnum = core.$constructor("ZodMiniEnum", (inst, def) => {
|
|
@@ -731,7 +731,7 @@ function _enum(values, params) {
|
|
|
731
731
|
return new exports.ZodMiniEnum({
|
|
732
732
|
type: "enum",
|
|
733
733
|
entries,
|
|
734
|
-
...
|
|
734
|
+
...util.normalizeParams(params),
|
|
735
735
|
});
|
|
736
736
|
}
|
|
737
737
|
// @__NO_SIDE_EFFECTS__
|
|
@@ -746,7 +746,7 @@ function nativeEnum(entries, params) {
|
|
|
746
746
|
return new exports.ZodMiniEnum({
|
|
747
747
|
type: "enum",
|
|
748
748
|
entries,
|
|
749
|
-
...
|
|
749
|
+
...util.normalizeParams(params),
|
|
750
750
|
});
|
|
751
751
|
}
|
|
752
752
|
exports.ZodMiniLiteral = core.$constructor("ZodMiniLiteral", (inst, def) => {
|
|
@@ -758,7 +758,7 @@ function literal(value, params) {
|
|
|
758
758
|
return new exports.ZodMiniLiteral({
|
|
759
759
|
type: "literal",
|
|
760
760
|
values: Array.isArray(value) ? value : [value],
|
|
761
|
-
...
|
|
761
|
+
...util.normalizeParams(params),
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
764
|
exports.ZodMiniFile = core.$constructor("ZodMiniFile", (inst, def) => {
|
|
@@ -828,7 +828,7 @@ function _default(innerType, defaultValue) {
|
|
|
828
828
|
type: "default",
|
|
829
829
|
innerType: innerType,
|
|
830
830
|
get defaultValue() {
|
|
831
|
-
return typeof defaultValue === "function" ? defaultValue() :
|
|
831
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
832
832
|
},
|
|
833
833
|
});
|
|
834
834
|
}
|
|
@@ -842,7 +842,7 @@ function prefault(innerType, defaultValue) {
|
|
|
842
842
|
type: "prefault",
|
|
843
843
|
innerType: innerType,
|
|
844
844
|
get defaultValue() {
|
|
845
|
-
return typeof defaultValue === "function" ? defaultValue() :
|
|
845
|
+
return typeof defaultValue === "function" ? defaultValue() : util.shallowClone(defaultValue);
|
|
846
846
|
},
|
|
847
847
|
});
|
|
848
848
|
}
|
|
@@ -855,7 +855,7 @@ function nonoptional(innerType, params) {
|
|
|
855
855
|
return new exports.ZodMiniNonOptional({
|
|
856
856
|
type: "nonoptional",
|
|
857
857
|
innerType: innerType,
|
|
858
|
-
...
|
|
858
|
+
...util.normalizeParams(params),
|
|
859
859
|
});
|
|
860
860
|
}
|
|
861
861
|
exports.ZodMiniSuccess = core.$constructor("ZodMiniSuccess", (inst, def) => {
|
|
@@ -935,7 +935,7 @@ function templateLiteral(parts, params) {
|
|
|
935
935
|
return new exports.ZodMiniTemplateLiteral({
|
|
936
936
|
type: "template_literal",
|
|
937
937
|
parts,
|
|
938
|
-
...
|
|
938
|
+
...util.normalizeParams(params),
|
|
939
939
|
});
|
|
940
940
|
}
|
|
941
941
|
exports.ZodMiniLazy = core.$constructor("ZodMiniLazy", (inst, def) => {
|
|
@@ -972,7 +972,7 @@ exports.ZodMiniCustom = core.$constructor("ZodMiniCustom", (inst, def) => {
|
|
|
972
972
|
function check(fn, params) {
|
|
973
973
|
const ch = new core.$ZodCheck({
|
|
974
974
|
check: "custom",
|
|
975
|
-
...
|
|
975
|
+
...util.normalizeParams(params),
|
|
976
976
|
});
|
|
977
977
|
ch._zod.check = fn;
|
|
978
978
|
return ch;
|
package/v4/mini/schemas.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from "../core/index.cjs";
|
|
2
|
-
import
|
|
2
|
+
import * as util from "../core/util.cjs";
|
|
3
3
|
type SomeType = core.SomeType;
|
|
4
4
|
export interface ZodMiniType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
|
|
5
5
|
type: Internals["def"]["type"];
|
package/v4/mini/schemas.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
|
-
import
|
|
2
|
+
import * as util from "../core/util.js";
|
|
3
3
|
type SomeType = core.SomeType;
|
|
4
4
|
export interface ZodMiniType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {
|
|
5
5
|
type: Internals["def"]["type"];
|
package/v4/mini/schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as core from "../core/index.js";
|
|
2
|
-
import
|
|
2
|
+
import * as util from "../core/util.js";
|
|
3
3
|
import * as parse from "./parse.js";
|
|
4
4
|
export const ZodMiniType = /*@__PURE__*/ core.$constructor("ZodMiniType", (inst, def) => {
|
|
5
5
|
if (!inst._zod)
|
package/v4-mini/index.cjs
CHANGED
|
@@ -10,8 +10,23 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
10
|
if (k2 === undefined) k2 = k;
|
|
11
11
|
o[k2] = m[k];
|
|
12
12
|
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
13
25
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
26
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
27
|
};
|
|
16
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
29
|
+
exports.z = void 0;
|
|
30
|
+
const z = __importStar(require("../v4/mini/external.cjs"));
|
|
31
|
+
exports.z = z;
|
|
32
|
+
__exportStar(require("../v4/mini/external.cjs"), exports);
|
package/v4-mini/index.d.cts
CHANGED
package/v4-mini/index.d.ts
CHANGED
package/v4-mini/index.js
CHANGED