MCPcopy
hub / github.com/colinhacks/zod / normalizeDef

Function normalizeDef

packages/zod/src/v4/core/schemas.ts:1838–1854  ·  view source on GitHub ↗
(def: $ZodObjectDef)

Source from the content-addressed store, hash-verified

1836> extends $ZodType<any, any, $ZodObjectInternals<Shape, Params>> {}
1837
1838function normalizeDef(def: $ZodObjectDef) {
1839 const keys = Object.keys(def.shape);
1840 for (const k of keys) {
1841 if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1842 throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1843 }
1844 }
1845 const okeys = util.optionalKeys(def.shape);
1846
1847 return {
1848 ...def,
1849 keys,
1850 keySet: new Set(keys),
1851 numKeys: keys.length,
1852 optionalKeys: new Set(okeys),
1853 };
1854}
1855
1856function handleCatchall(
1857 proms: Promise<any>[],

Callers 1

schemas.tsFile · 0.85

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected