You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some of the schemas in this.zodSchemas.models are of type ZodObject, but it seems like any models that have model level validation on it along with polymorphic extensions of it are of type ZodEffects . (in img below, the User model is derived from the Entity model)
Testing
Problem is resolved if I remove any @@validate functions
ZModel
(sidenote: please don't be alarmed by the overly permissive @@allow() s, still in early development)
abstract model Base {
id String @id @default(uuid()) @deny('update', true)
createdAt DateTime @default(now()) @deny('update', true)
updatedAt DateTime @updatedAt @deny('update', true)
active Boolean @default(false)
published Boolean @default(true)
deleted Boolean @default(false)
startDate DateTime?
endDate DateTime?
@@allow('create', true)
@@allow('read', true)
@@allow('update', true)
}
enum EntityType {
User
Alias
Group
Service
Device
Organization
Guest
}
model Entity extends Base {
entityType EntityType
name String? @unique
members Entity[] @relation("members")
memberOf Entity[] @relation("members")
@@delegate(entityType)
@@allow('create', true)
@@allow('read', true)
@@allow('update', true)
@@validate(!active || (active && name != null), "Active Entities Must Have A Name")
}
model User extends Entity {
profile Json?
username String @unique
password String @password
@@allow('create', true)
@@allow('read', true)
@@allow('update', true)
}
Environment (please complete the following information):
ZenStack version: 2.11.6
Prisma version: 6.3.1
Database type: SQLite
Zod Version : 3.24.2
The text was updated successfully, but these errors were encountered:
Thanks for filing this @breagan1983 . The @password and @@validation combination is untested and doesn't work 😢 . You're right, the problem is after zod refinement the schema is not an ZodObject anymore and cannot be further merged.
I'll make a fix to use the pre-refine schema for merging and then reapply the refinement. A bit awkward but it should work.
Error
policy-utils.ts:1387
Description and expected behavior
db.user.create({data: {username: 'admin', password: 'abc12345'}})
db.user.update({where: {username: 'admin'}, data: {password: 'abc123456789123'}})
db.user.upsert({where: {username: 'admin'}, update: {username: 'admin2'}, create: {username: 'admin', password: 'abc123456789'}})
Additional Context*
this.zodSchemas.models
are of typeZodObject
, but it seems like any models that have model level validation on it along with polymorphic extensions of it are of typeZodEffects
. (in img below, the User model is derived from the Entity model)Testing
@@validate
functionsZModel
(sidenote: please don't be alarmed by the overly permissive
@@allow()
s, still in early development)Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: