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

validateProvidedData with mongoose format #44

Open
soullivaneuh opened this issue Jan 31, 2021 · 4 comments
Open

validateProvidedData with mongoose format #44

soullivaneuh opened this issue Jan 31, 2021 · 4 comments
Labels

Comments

@soullivaneuh
Copy link

As specified on the doc, the validate.validateProvidedData method provides the same result as validate.form.

However, I am using validate.mongoose because I prefer this format.

Because of this, I can not use the partial validation feature you propose.

Is that a reason to not support mongoose format for validateProvidedData?

Thanks

@soullivaneuh
Copy link
Author

Just to try, I replaced form by mongoose on this line:

const validateHook = validators.form(patchSchema, joiOptions);

Works like a charm.

A refactor may be done with ease to provide methods like this:

  • validate.form
  • validate.formWithProvidedData (currently validateProvidedData)
  • validate.mongoose
  • validate.mongooseWithProvidedData

What do you think?

I may work on a PR for this.

@soullivaneuh
Copy link
Author

I just made a proposition in #45

@soullivaneuh
Copy link
Author

soullivaneuh commented Feb 6, 2021

If anyone is also stuck by this limitation, here is an hacky workaround:

# To be run by postinstall
#!/usr/bin/env sh
set -e

# Hack to be remove when both format will be supported.
# @see https://github.com/feathersjs-ecosystem/validate-joi/pull/45
sed -i 's/validators\.form/validators.mongoose/' node_modules/feathers-validate-joi/index.js

Then validate.validateProvidedData will use the mongoose format.

However, this solution does not work if you need both formats.

@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Apologies if the issue could not be resolved. FeathersJS ecosystem modules are community maintained so there may be a chance that there isn't anybody available to address the issue at the moment. For other ways to get help see here.

@stale stale bot added the wontfix label Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant