Skip to content

Commit 17e91fe

Browse files
committed
fix(zod): generate optional field as z.optional() rather than z.nullish() to be consistent with Prisma's typing
1 parent 5806a4d commit 17e91fe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/schema/src/plugins/zod/utils/schema-gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ export function makeFieldSchema(field: DataModelField) {
144144
// field uses `auth()` in `@default()`, this was transformed into a pseudo default
145145
// value, while compiling to zod we should turn it into an optional field instead
146146
// of `.default()`
147-
schema += '.nullish()';
147+
schema += '.optional()';
148148
} else {
149149
const schemaDefault = getFieldSchemaDefault(field);
150150
if (schemaDefault !== undefined) {
151151
schema += `.default(${schemaDefault})`;
152152
}
153153

154154
if (field.type.optional) {
155-
schema += '.nullish()';
155+
schema += '.optional()';
156156
}
157157
}
158158

0 commit comments

Comments
 (0)