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

Custom npm package for object validation? #357

Closed
wolfiton opened this issue Jun 11, 2019 · 2 comments
Closed

Custom npm package for object validation? #357

wolfiton opened this issue Jun 11, 2019 · 2 comments
Labels
Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request Solved ✔️ The issue has been solved
Projects
Milestone

Comments

@wolfiton
Copy link

Hello,

I want to implement my custom validation using an external package that can be found in this git repo https://github.com/oussamahamdaoui/forgJs.

How can I replace the class-validator with forgJS?

Can I have a schema wide validation for all my objects?

Thanks in advance

@wolfiton wolfiton changed the title Custom npm package for object validation Custom npm package for object validation? Jun 11, 2019
@MichalLytek MichalLytek added the Question ❔ Not future request, proposal or bug issue label Jun 17, 2019
@MichalLytek
Copy link
Owner

You can use middleware for that purpose and wrap it in a method decorator, just like in docs for joi:
https://typegraphql.ml/docs/custom-decorators.html#method-decorators

In the future with #123 you will have an access to the metadata like MyArgs class, so no need to manually provide validate schema if you can derivate it from a class.

I will also try to rewrite the core to add a special support for validation lib in plugins 😉

@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request and removed Question ❔ Not future request, proposal or bug issue labels Jun 23, 2019
@MichalLytek MichalLytek added this to Backlog in Board via automation Jun 23, 2019
@MichalLytek MichalLytek added this to the 2.0.0 release milestone Jun 23, 2019
@MichalLytek
Copy link
Owner

Closing this one via 3c767e6 🔒

@wolfiton you can now use provide your own validate function implementation that will call forgJS.

@MichalLytek MichalLytek moved this from Backlog to Done in Board Oct 12, 2020
@MichalLytek MichalLytek added the Solved ✔️ The issue has been solved label Oct 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community 👨‍👧 Something initiated by a community Enhancement 🆕 New feature or request Solved ✔️ The issue has been solved
Projects
Board
  
Done
Development

No branches or pull requests

2 participants