question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow custom field attributes

See original GitHub issue

Let’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:open
  • Created 3 years ago
  • Reactions:50
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
Mark-Pandacommented, Nov 3, 2021

When is it expected to be achieved

7reactions
pantharshit00commented, Jul 23, 2020

Another idea: @custom(email)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom Field Attributes - Salesforce Help
A custom field entry consists of several attributes. ... Determines how a roll-up summary field is recalculated after its properties change.
Read more >
Adding custom fields to user attributes - Userlane Help Center
Custom data are fields that you can add as user attributes to your user profiles. They can be filled with data. This data...
Read more >
Configuring Attributes for Custom Fields
All configurations are applied per field and it is not possible to alter the default settings when mapping custom fields that are not...
Read more >
Steps for defining a custom field and its attributes - IBM
Perform the following steps to define a new custom field. Issue the RDEFINE command to define a new custom field and its attributes....
Read more >
Custom Fields: Add Personalized Attributes
Once you have selected "Create Custom Field" you will then have the ability to name the attribute, chose where this field will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found