From 4e1450671720f97aee825717d2bf405a8e05fcd6 Mon Sep 17 00:00:00 2001 From: Eric Butler Date: Tue, 19 Dec 2023 10:37:45 -0500 Subject: [PATCH] Revert "fix(zod): allow blank value for non-required enums (#1113)" This reverts commit 1edc2ab5dde2326afd2834d190a1b3ae0dc04d36. --- packages/zod/src/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/zod/src/index.ts b/packages/zod/src/index.ts index c281f3ce6..4c4d4d5ee 100644 --- a/packages/zod/src/index.ts +++ b/packages/zod/src/index.ts @@ -214,13 +214,14 @@ const generateZodValidationSchemaDefinition = ( } if (schema.enum && type !== 'number') { - const enumValues = schema.enum.map((value) => - isString(value) ? `'${escape(value)}'` : `${value}`, - ); - if (!schema.required) { - enumValues.push(`""`); - } - functions.push(['enum', [`[${enumValues.join(', ')}]`]]); + functions.push([ + 'enum', + [ + `[${schema.enum + .map((value) => (isString(value) ? `'${escape(value)}'` : `${value}`)) + .join(', ')}]`, + ], + ]); } if (!required && nullable) {