Skip to content

[Feature Request] Support future() function in field-level policy rules #671

Open

Description

@ymc9

Right now you can't use future() to check for post-update values in field-level rules. The workaround is to use a model-level rule instead.

People may desire such a support so rules are more "localized" on fields:

model User {
    ....
    role Role @default(user) @allow('update', auth().role == 'superadmin' && future() != 'superadmin')
}

Activity

  1. sagspot commented on Sep 4, 2023

    @sagspot

    Sounds good.
    This could be flexible, such that it can be used both in field-level and model-level.

    model User {
      ...
      role Role @default(user) @allow('update', future() != 'superadmin')
      ...
      @@allow('update', future().role != 'superadmin')
    }

    This will give people the freedom to use that which suits their apps best

  2. added this to the v2.0.0 milestone on Dec 7, 2023
  3. modified the milestones: v2.0.0, v2.x on May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions