Skip to content

Commit 490f805

Browse files
committed
CR: defensive init of the bag in pack().
1 parent 98b8a9f commit 490f805

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

zod-plugin/packer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const pack = <T extends z.ZodType, B extends object>(
2525
const Cls = z.core.$constructor<$Packer<B>>("$Packer", (inst, def) => {
2626
z.core.$ZodCheck.init(inst, def);
2727
inst._zod.onattach.push((schema) => {
28+
if (!schema._zod.bag) schema._zod.bag = {}; // Defensive init
2829
Object.assign(schema._zod.bag, def.bag);
2930
});
3031
inst._zod.check = () => {};

0 commit comments

Comments
 (0)