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

Closed
pstoica opened this issue Sep 17, 2014 · 1 comment
Closed

Returning original attributes from validator/promise #25

pstoica opened this issue Sep 17, 2014 · 1 comment

Comments

@pstoica
Copy link

@pstoica 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?

@ansman
Copy link
Contributor

@ansman 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 in 89f0b98 Sep 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants