Skip to content

Commit 7580f55

Browse files
author
Eric Butler
authoredDec 19, 2023
Revert "fix(zod): allow blank value for non-required enums (#1113)" (#1116)
This reverts commit 1edc2ab.
1 parent f9a2c38 commit 7580f55

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed
 

‎packages/zod/src/index.ts

+8-7
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,14 @@ const generateZodValidationSchemaDefinition = (
214214
}
215215

216216
if (schema.enum && type !== 'number') {
217-
const enumValues = schema.enum.map((value) =>
218-
isString(value) ? `'${escape(value)}'` : `${value}`,
219-
);
220-
if (!schema.required) {
221-
enumValues.push(`""`);
222-
}
223-
functions.push(['enum', [`[${enumValues.join(', ')}]`]]);
217+
functions.push([
218+
'enum',
219+
[
220+
`[${schema.enum
221+
.map((value) => (isString(value) ? `'${escape(value)}'` : `${value}`))
222+
.join(', ')}]`,
223+
],
224+
]);
224225
}
225226

226227
if (!required && nullable) {

0 commit comments

Comments
 (0)
Please sign in to comment.