-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
.with and .without accept an array of args as well #107
Comments
How would |
var args = Array.isArray(arguments[0]) ? arguments[0].concat(arguments.slice(1) : arguments Its an idea and by the looks you aren't fond of it, you could argue what if's all day |
I am not opposed to it, but can't think of a good use case. Any thoughts on a valid use case? The other edge case may be |
So this isn't really about expanding to a new use case its more of increasing usability. This is quite possibly the wrong approach to the problem I encountered. When I incorrectly used arrays i received this as a response:
It is my understanding that the .with/.without should only ever have other key names of the object you are validating as input, so those methods are only expecting strings as input. When it received an array it choked and said the payload was invalid when it tried to check and see if the key maybe a more appropriate action would be to check and make sure arguments only contains strings? and to throw an error with inappropriate use of the method. calling the method like so: If you understand what I'm saying better than we can:
Overall you are correct, there isn't a great use case for it. I made the mistake and it wasn't clear what the problem was until I dug a little deeper. |
Awesome idea, we should throw when the args aren't strings. Do you want to do a PR for this? |
sure. |
I made a boo boo and passed an array to these methods instead of calling the method with them as individual parameters, fixed my mistake after realizing I was doing it wrong via the crypt 400 response and second look at the readme, but was wondering if you would be open to that as an acceptable form of input, for example:
instead of:
If you don't like the idea then we can close the issue otherwise I'll send a pull request later.
The text was updated successfully, but these errors were encountered: