Allow custom field attributes
See original GitHub issueLet’s say I want to make sure, that an email is always valid before it gets created.
It would be awesome, if I could add an @email
directive like so:
model User {
id Int @id
email String @unique @email
}
While it makes sense, that @email
is not allowed right now, if we would allow it, users could now add an email validation middleware.
Allowing top-level @email
probably doesn’t make sense though to keep validation rather strict so that we can also help with typos.
However, the same as in HTTP Headers, which can start with X-
or HTML attributes, which can start with data-
, we could add a namespace for custom directives, for example @custom.X
.
That would allow a whole world of extensions for Prisma, which can be dealt with through middlewares.
And of course, this is just a wild idea, it could also just be trash and maybe we shouldn’t do it. So let’s have a discussion if this even makes sense 😃
Issue Analytics
- State:
- Created 3 years ago
- Reactions:50
- Comments:17 (4 by maintainers)
When is it expected to be achieved
Another idea:
@custom(email)