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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

Show comment
Hide comment
@ansman

ansman Sep 23, 2014

Contributor

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! :)

Contributor

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