Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jc/zod schemas #24

Merged
merged 10 commits into from
Jan 10, 2024
Merged

Jc/zod schemas #24

merged 10 commits into from
Jan 10, 2024

Conversation

jcharlpretorius
Copy link
Collaborator

@jcharlpretorius jcharlpretorius commented Jan 8, 2024

Validation with Zod and zod-prisma-types:

  • Schemas are generated from Prisma models and can be manually extended or modified to omit certain fields as needed, see shared/schemas.ts
  • We can add rich comments (/// triple slash comments) to models in schema.prisma to add Zod field validators on the generated schemas, also useful for customizing validation error messages
  • Schemas are stored in a shared folder and can be used on both the backend and frontend
  • Types can be inferred from schemas using type TmySchema = z.infer

Other changes:

  • Modify scripts in backend package.json
  • Updated Prisma schema and seed scripts
  • Installed Prettier code formatter
  • Updated Github actions workflow to install dependencies (Zod) in shared folder

@AarshShah9
Copy link
Owner

Mostly looks good! Great work, just need to resolve merge conflicts incurred due to the latest PR merge and should be good to merge :).

@AarshShah9 AarshShah9 merged commit 5c7376f into main Jan 10, 2024
3 checks passed
@jcharlpretorius jcharlpretorius deleted the JC/Zod-schemas branch January 19, 2024 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants