Skip to content

@url validation requires @id or @unique attribute, or a model-level @@id or @@unique. #965

@AlekseiAQ

Description

@AlekseiAQ

Description and expected behavior
@url validation requires @id or @unique attribute, or a model-level @@id or @@unique. Per our discord conversation, that seems to be a bug, and it should not be required.

Screenshots

The error message:

Model must include a field with @id or @unique attribute, or a model-level @@id or @@unique attribute to use access policieszmodel
Validates a string field value is a valid url.

If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • ZenStack version: "zenstack": "1.7.0"
  • Prisma version: "prisma": "^5.8.1"
  • Database type: Planetscale mysql

Additional context
An example where 2 models trying to extend multiple abstract models with @url validations and a model with id can't be extended in all the required places

abstract model Base {
    id String @id @default(cuid())
}

abstract model A {
    URL String? @url
}

abstract model B {
    anotherURL String? @url
}

abstract model C {
    oneMoreURL String? @url
}

model D extends A, B {
}

model E extends B, C {
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions