-
Notifications
You must be signed in to change notification settings - Fork 996
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
Disallow multiple arguments (array) for a key #229
Comments
@Congelli501 Thanks for the suggestion! Seems reasonable enough, but I'd probably prefer not to overload the current
I'm not sure which would provide the most bang for the buck. Thoughts? |
So I would prefer method 0 or 1. |
@Congelli501 Ok. We can possibly overload
From this, we'd have to fix at least 4, 5, 10, and 11 (stop ignoring count) and add the following:
I'd be a little concerned about how to properly document this. Just add one of these? demand(key, count, [max], [msg])demand(key, count, [max | msg], [msg])I guess as long as we always require two number arguments in order to specify a max count, then this is doable. |
My two cents, I don't particularly want to add many more dials and knobs to If this is something you're concerned about in your application, I like @nexdrew's suggestion of coercion -- which is a feature I think we can add fairly elegantly, and addresses other people's issues. alternatively, perhaps we can introduce an additional argument to |
I think this issue is very important, and could even be considered a security issue:
if (path[0] === '/') {
throw new Error('must be relative')
}
// Can remove path or each elements of path
deepRemove(path, callback);
This 3 factors cocktail can lead to very dangerous behaviour, or an application crash (which I also consider a security problem). IMAO, the Array feature should be only activated explicitly, but that would break backward compatibility. |
Note that we're planning on adding coercion to the API in 5.x. See #586. |
Related #530 The Array feature can now be disabled. |
@Congelli501 as @laggingreflex indicates, the array feature can now be disabled in configuration. |
I would be great to have a way to prevent Array transformation of a duplicated argument.
For example, --file foo.xml --file bar.xml would lead to an error, instead of the array
['foo.xml', 'bar.xml']
. Most of the time, I don't want this to append, as my code assume it will get a string, and not an array.Something like
demand(<key>, <min>, [max])
for each arguments would be great.demand('file', 0, 1)
: no file arguments, or only onedemand('file', 1, 1)
would require the argument, and only one (no Array)demand('file', 1)
would require at least one argument (same behaviour as the current one)demand('file', 1, 3)
would require one to 3 file arguments. For this one, the returned result should only be an array, as we are waiting for multiple arguments.The text was updated successfully, but these errors were encountered: