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

External validation alternative #2424

Closed
renanBritz opened this issue Jul 29, 2020 · 2 comments
Closed

External validation alternative #2424

renanBritz opened this issue Jul 29, 2020 · 2 comments
Assignees
Labels
support Questions, discussions, and general support

Comments

@renanBritz
Copy link

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 12.7.0
  • module version: ^17.1.1
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...): nestjs
  • any other relevant information:

How can we help?

Hello!

For async validation (e.g check if username is unique in database) you have recommended multiple times to use external() validator, but it's not a good solution! Simply because it offers no context to which field presented the error, and it runs AFTER the rest of the schema has been validated. Or am I missing something in the documentation?

I don't know if this is a design limitation, but it's simply not helpful to developers.

I don't mean to be disrespectful, but such a large library that handles a very important aspect of a server-side app needs to add more consideration to this common use case.

Regards!

@hueniverse
Copy link
Contributor

I plan to improve the external user experience in the future. That said, while this is a somewhat common use case, it is still less common than using joi for sync validations and unfortunately in JS you can have both in the same code. This would require duplicating the entire library.

@hueniverse hueniverse self-assigned this Jul 29, 2020
@hueniverse hueniverse added the support Questions, discussions, and general support label Jul 29, 2020
@jonyeezs
Copy link

PR #2773 may solve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

3 participants