Files
SnowLuma/.pnpm-store/v11/files/2b/61515beae8cfa19254a561888c390e2ee6f2cfbb5de84472b44abbc867d73c4ea6037275f54ca22ceeb831e7158df04466ebd36368f3fc5585a4abd4f657d6
T
TanTan 2a69b23b47
Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:27:07 +08:00

14 lines
543 B
Plaintext

import { visit } from "../core/visit.js";
import * as schemas from "./schemas.js";
/** Returns a copy of the schema with every nested object's properties made optional. */
export function deepPartial(schema) {
return visit(schema, {
object: (s) => s.partial(),
// Every partialed option now admits `undefined`, which the constructor rejects as a duplicate.
union: (s) => {
const def = s._zod.def;
return def.discriminator === undefined ? s : schemas.union(def.options);
},
});
}