UNPKG

prisma-zod-generator

Version:

Prisma 2+ generator to emit Zod schemas from your Prisma schema

18 lines 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.changeOptionalToRequiredFields = changeOptionalToRequiredFields; function changeOptionalToRequiredFields(inputObjectTypes) { inputObjectTypes.map((item) => { var _a, _b, _c; if (item.name.includes('WhereUniqueInput') && ((_b = (_a = item.constraints.fields) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) { const uniqueFields = (_c = item.constraints.fields) !== null && _c !== void 0 ? _c : []; // Keep original optionality; do NOT force unique fields required. // Restrict WhereUniqueInput to ONLY the unique identifier fields. // This avoids leaking WhereInput-style fields (AND/OR/NOT, filters) into WhereUniqueInput. const updatedFields = item.fields.filter((subItem) => uniqueFields.includes(subItem.name)); item.fields = updatedFields; } return item; }); } //# sourceMappingURL=whereUniqueInput-helpers.js.map