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

Method partial

packages/zod/src/v3/types.ts:2823–2840  ·  view source on GitHub ↗
(mask?: any)

Source from the content-addressed store, hash-verified

2821 Catchall
2822 >;
2823 partial(mask?: any) {
2824 const newShape: any = {};
2825
2826 for (const key of util.objectKeys(this.shape)) {
2827 const fieldSchema = this.shape[key]!;
2828
2829 if (mask && !mask[key]) {
2830 newShape[key] = fieldSchema;
2831 } else {
2832 newShape[key] = fieldSchema.optional();
2833 }
2834 }
2835
2836 return new ZodObject({
2837 ...this._def,
2838 shape: () => newShape,
2839 }) as any;
2840 }
2841
2842 required(): ZodObject<{ [k in keyof T]: deoptional<T[k]> }, UnknownKeys, Catchall>;
2843 required<Mask extends util.Exactly<{ [k in keyof T]?: true }, Mask>>(

Callers

nothing calls this directly

Calls 1

optionalMethod · 0.80

Tested by

no test coverage detected