Skip to content

adding plugin @core/enhancer breaks validation checks for @core/zod plugin #1562

Closed
@tmax22

Description

@tmax22

I have no idea why, but adding plugin @core/enhancer breaks validation checks for @core/zod plugin

✅ Good

in the following schema, ^[a-zA-Z0-9_]{3,30}$ regex validation would correctly take place on User.name:

generator client {
    provider = "prisma-client-js"
}

datasource db {
    provider = "postgresql"
    url      = env("DATABASE_URL")
}

plugin hooks {
    provider = '@zenstackhq/tanstack-query'
    target = 'react'
    version = 'v5'
    output = 'src/hooks/generated'
}

plugin zod {
    provider = '@core/zod'
}

model User extends Base {
    name String @unique @regex('^[a-zA-Z0-9_]{3,30}$')

    @@allow('read', true)
}

image

❌ Bad

surprisingly enough, adding plugin enhancer plugin to the previous schema would result in @regex validation on User.name to be completely ignored:

generator client {
    provider = "prisma-client-js"
}

datasource db {
    provider = "postgresql"
    url      = env("DATABASE_URL")
}

plugin hooks {
    provider = '@zenstackhq/tanstack-query'
    target = 'react'
    version = 'v5'
    output = 'src/hooks/generated'
}

plugin zod {
    provider = '@core/zod'
}
plugin enhancer {
    provider = '@core/enhancer'
    generatePermissionChecker = true
}

abstract model Base {
    id        String   @id @default(uuid())
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt()

    // require login
    @@allow('all', true)
}

model User extends Base {
    name String @unique @regex('^[a-zA-Z0-9_]{3,30}$')

    @@allow('read', true)
}

image

also tried to move around the enhancer plugin to check if its order related issue, it's not.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions