UNPKG

altair-graphql-core

Version:

Several of the core logic for altair graphql client

24 lines 873 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.stripDefaults = stripDefaults; const v4_1 = require("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 */ function stripDefaults(schema) { const shape = schema.shape; const newShape = {}; Object.entries(shape).forEach(([key, value]) => { // Remove default if present const newValue = value instanceof v4_1.z.ZodDefault ? value.def.innerType : value; newShape[key] = newValue; }); return v4_1.z.object(newShape); } //# sourceMappingURL=schema.js.map