-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Allow for Prisma enums in validation rules #1211
Comments
Hey @nwidynski , thanks for filing this. Do you mind providing a ZModel snippet showing how you want to use it? Thanks! |
@ymc9 This would be a short example with some options for the validate API.
|
Got it. Yes, string and enum can be compatible for comparison. |
We‘re especially looking for the in operator which would probably translate to: Object.values(PostStatus).includes(value) |
I actually don't get why this is necessary. Making |
@Eliav2 It's mentioned at the bottom of the issue description. Also both the |
Is your feature request related to a problem? Please describe.
While Zenstack is already offering great validation capabilities, it would be nice if it were possible to use Prisma enums
inside a validate block, for example with an
in
operation. This would allow for an always-in-sync validation instead of relying on manual updates in both codebase and validation rules.One might ask why not set the field as the enum? The answer to that being that working with primitives is easier to migrate and also better supported across third party vendors, like Hasura GraphQL.
Describe the solution you'd like
Allow for Prisma enums to be referenced in validations rules, especially with the
in
operator.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: