Hello Does anyone know of resources or a strategy ...
# orm-help
j
Hello Does anyone know of resources or a strategy someone has used for data mapper like validation at runtime for Prisma? our stack uses nest and graphql and we are seeing that while we can use DTO and validation pipes at the inputs for an entity we cannot easily make sure that same validation is applied before update. for Example if a model as a
startsAt
and
endsAt
we will add decorators to the entity so that
startsAt < endsAt
and vice versa. However when input for update comes in we only get the time to update and not both. we need a layer that checks that the update is valid before we call
Prisma.client.model.update()
to update the model.
Prisma.Client
does not know about the validation and it’s not applicable in the
Prisma.Schema
. Does anyone know of an elegant way to handle this need?
n
Hey Jacob 👋 You might want to have a look at zod-prisma to define validations at your schema level