Skip to content

@@validate() fails validation when update payload doesn't have property. #1078

@nwidynski

Description

@nwidynski

Description and expected behavior
When implementing model-level validation and running UPDATE actions, Zenstack doesn't pass non-existent properties.
Since a property isn't mutated when its not passed, it should not invalidate the action.

Screenshots

model Counter {
  id String @id

  name String
  value Int

  @@validate(value >= 0)
}
const client = new PrismaClient();

const counter = await client.counter.create({
  data: { id: "1", name: "It should create", value: 1 }
})

//! This query fails validation
const updated = await client.counter.update({
  where: { id: "1" },
  data: { name: "It should update" } 
})

Environment (please complete the following information):

  • ZenStack version: latest
  • Prisma version: latest
  • Database type: Postgresql

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions