UNPKG

altair-graphql-core

Version:

Several of the core logic for altair graphql client

21 lines 750 B
import { z } from 'zod/v4'; /** * This function strips default values from a Zod object schema, returning a new schema * that does not include any default values. This is useful when you want to * validate data without applying defaults. * * NOTE: This function only strips top-level defaults and does not handle nested schemas. * @param schema * @returns */ export function stripDefaults(schema) { const shape = schema.shape; const newShape = {}; Object.entries(shape).forEach(([key, value]) => { // Remove default if present const newValue = value instanceof z.ZodDefault ? value.def.innerType : value; newShape[key] = newValue; }); return z.object(newShape); } //# sourceMappingURL=schema.js.map