Validate Model
Problematic
I would like to use
Prisma.validator
(or something else provided by Prisma) in order to validate a model
Context
Solutions
I know i can override the Model
in order to pass the name of the model but would really like to make it the cleanest possible and use only Prisma.
I also know you can create type guard functions using the uniques fields of my model but same thing not as clean as using a Prisma function.
ex:
Resources
- https://github.com/prisma/prisma/issues/3528
Thank you for your time if you help me with this :prismasmile:Solution:Jump to solution
Finally created a function that answers this question in case anyone needs it
```ts
export type GetModel<T extends Prisma.ModelName> = Exclude<
Awaited<ReturnType<PrismaClient[Uncapitalize<T>]["findUnique"]>>,
null...
1 Reply
Solution
Finally created a function that answers this question in case anyone needs it
Example usage: