An Interest In:
Web News this Week
- March 21, 2024
- March 20, 2024
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
May 12, 2022 07:07 pm GMT
Original Link: https://dev.to/omardulaimi/how-to-automatically-generate-yup-schemas-from-your-prisma-schema-5ao5
How to automatically generate Yup schemas from your Prisma schema
Here's what you need to do:
1- Install the generator
- Using npm
npm install prisma-yup-generator
- Using yarn:
yarn add prisma-yup-generator
2- Add the generator to your Prisma schema
generator yup { provider = "prisma-yup-generator"}
3- Run npx prisma generate
for your schema(or the example below)
model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[]}model Post { id Int @id @default(autoincrement()) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt title String content String? published Boolean @default(false) viewCount Int @default(0) author User? @relation(fields: [authorId], references: [id]) authorId Int?}
Now you will have all possible Yup schemas generated for you!
Original Link: https://dev.to/omardulaimi/how-to-automatically-generate-yup-schemas-from-your-prisma-schema-5ao5
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To