DEV Community

Thomas Reggi
Thomas Reggi

Posted on

Why can't we have one definition for Component Props, Database Tables, and Validation?

One pain point I often expierence is that we have so many repeat definitions for things. Tools like TRPC, ZOD, JSON Schema, AJV, TypeORM, and Prisma all pop up to solve a problem, but soon they collide with what each other are doing, and it's frustrating. I wish we had one way to define a 'schema' that did the following:

  1. exports TypeScript types (ZOD does this brilliantly with input and output types chef's kiss)
  2. defines a database schema
  3. provides functions for validation (something that works both on the client, and server)

TypeORM comes closest to fulfilling all three requirements, but it comes with a lot of heft. The input/output types can be confusing, and I fear using decorators as they are not yet standardized.

Interestingly I just discovered zod-prisma which may be a good solution to my problems.

Top comments (0)