Skip to content
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

decorator comments to specify validator #3

Open
Morriz opened this issue May 29, 2022 · 4 comments
Open

decorator comments to specify validator #3

Morriz opened this issue May 29, 2022 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@Morriz
Copy link

Morriz commented May 29, 2022

Problem

Hi, Prisma only has simple validation for database fields, but Yup/Joi etc allow have richer validators such as email/regex etc. How much work would it be to put the desired validator+args in decorator comments and apply them in the generator to the ones already picked up?

Suggested solution

Example could be:

/// @PrismaYupGen email.nullable
// or 
/// @PrismaYupGen min(1).max(10)

To keep it simple I removed () from validator without args.

Hope to inspire :)

@omar-dulaimi omar-dulaimi added the enhancement New feature or request label May 29, 2022
@omar-dulaimi
Copy link
Owner

Hello @Morriz and thank you for the suggestion.

It actually seems like a great addition to the library. I'll give it a try soon to see if I could implement it with the current state of the project.

I'll let you know soon :)

@Morriz
Copy link
Author

Morriz commented May 29, 2022

Awesome! By the way, maybe the namespace could be @PrismaValGen to keep it generic, but only if it is possible to express the validators generically of course. It might be a headache to map them to the respective adapters

@omar-dulaimi omar-dulaimi self-assigned this May 31, 2022
@Morriz
Copy link
Author

Morriz commented Aug 7, 2022

Any updates here? Did you maybe try to create a PoC for this?

@omar-dulaimi
Copy link
Owner

Unfortunately, I hadn't had a chance to, and not sure if I will anytime soon.

So if you feel adventurous, you can work on it. I'll answer any questions you have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants