zod
zod copied to clipboard
Inconsistent input/output behavior between examples - is this intentional design?
const j = zod.null().transform(() => () => { });
let j1: zod.input<typeof j>; // null
let j2: zod.output<typeof j>; // () => void
let k = zod.function().args(j);
let k1: zod.input<typeof k>; // (args_0: () => void, ...args: unknown[]) => unknown
let k2: zod.output<typeof k>; // (args_0: null, ...args: unknown[]) => unknown
In this example, the input and output in 'j' are reversed compared to 'k'. I'd like to know if this contradictory behavior is intentionally designed this way?
zod version: 3.25.7
let i = zod.function().args(zod.string().optional());
i.parameters().parse([]); // ZodError: too_small
When a string is defined as optional, inputting an empty array ([]) should be considered valid. Is this the expected behavior?
This is correct & intended.