Trying to convert URL query to DB enum in procedure but not working...
Hey yall, I'm working on a Next.js application using tRPC and Prisma, and I've encountered an invalid_enum_value error when trying to filter service providers by category in my listing.getAll procedure. Here's the error message I'm receiving:
In my routers/listings.ts file, I have a getAll procedure that is supposed to validate the user input and map it to the expected enum using a getCategoryEnum function. Despite this, I'm still getting the above error.
Here's the relevant part of my listings.ts:
And here's the getCategoryEnum function defined in validation/listing.ts:
The ServiceCategory enum is defined in my Prisma schema and includes PCC as one of its values.
I'm not sure why the getCategoryEnum function isn't mapping the input 'Primary Care Consultations' to ServiceCategory.PCC as expected. Any insights into what might be causing this error or how to debug it further would be greatly appreciated.
0 Replies