PrismaP
Prisma8mo ago
6 replies
Mgs

Recommended Enum usage with Prisma and Zod

Currently, I have enums in my Prisma models which are also redefined in Zod schemas like this:
export const ItemRequestStatusEnum = z.nativeEnum(ItemRequestStatus);
export type ItemRequestStatusType = z.infer<typeof ItemRequestStatusEnum>;

Then, I may reference the type in my code like this:
interface ItemRequestTableProps {
  statusFilter: ItemRequestStatusType;
}


I've started wondering if I should remove the Zod enum/type and simply reference the ItemRequestStatus enum generated by Prisma. Is one approach recommended over the other?
Was this page helpful?