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

Returning original attributes from validator/promise #25

pstoica opened this issue Sep 17, 2014 · 1 comment

Returning original attributes from validator/promise #25

pstoica opened this issue Sep 17, 2014 · 1 comment


Copy link

pstoica commented Sep 17, 2014

Hey, I just started reading the docs for this and it seems like a good validation solution in node!

I haven't started using it yet, but I do have one suggestion. Using validate.async uses Promises but kind of drops composition by default by returning undefined if there are no errors. I could see it being more useful for chaining by returning the original attributes, or rejecting otherwise. The workaround would be to manually create success callbacks that return attributes, which would be redundant.

Not sure if this would be a breaking change, but maybe it can be an option in validate.async? What are your thoughts?

Copy link

ansman commented Sep 23, 2014

So if I understand you correctly this is what you are looking for:

validate.async(attrs, constaints)
  .then(function(validatedAttrs) {
      console.log(attrs === validatedAttrs); // Logs true
    }, function(error) {
      // Do something

This definitely sounds like a good idea! :)

@ansman ansman closed this as completed in 89f0b98 Sep 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants