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

Better validation of input #65

Open
gr0uch opened this issue Dec 9, 2013 · 2 comments
Open

Better validation of input #65

gr0uch opened this issue Dec 9, 2013 · 2 comments

Comments

@gr0uch
Copy link
Contributor

gr0uch commented Dec 9, 2013

Validation should be more strict and/or more informative. Examples:

/* I think there should be some sort of warning
   for trying to pass in an object, or if there is a
   clear type mismatch */
balanced.bankAccount.create({
  name: 1010001101010,
  routing_number: 123123123,
  account_number: {
    'omg': 'wtfbbq'
  }
}, function(res) {...}); // 201
/* same issue with functions, it makes the request
   though it does not serialize the `account_number`
   and thus it errors, could have been prevented */
balanced.bankAccount.create({
  name: 'foo bar',
  routing_number: 123123123,
  account_number: function(){}
}, function(res) {...}); // 400
/* it would be nice if `create` could return a promise using
   some lightweight promises lib that implements promises/A+ */
var promise = balanced.bankAccount.create({
  name: 'foo bar',
  routing_number: 123123123,
  account_number: 58294368
}); // cryptic error message due to minification, needs callback function parameter
balanced.bankAccount.create('foo'); // yay cryptic error
@mjallday
Copy link
Contributor

mjallday commented Dec 9, 2013

  1. library should not be minified - https://js.balancedpayments.com - let's make a new issue to un-minify that
  2. if you pass a function should we try and evaluate the response?
  3. by warning what do you mean? console.warn or something in the callback?
  4. I agree that promise could be nice.

@gr0uch
Copy link
Contributor Author

gr0uch commented Dec 9, 2013

1.) It would be nice to build an unminified version, but we should also not encourage its use in production.
2.) I don't think so, that would be too magical.
3.) console.warn should be sufficient.
4.) What about using Q or RSVP.js? they're both ~2.5kb minified+gzipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants