-
Notifications
You must be signed in to change notification settings - Fork 118
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
Incorrect default
type should not be allowed
#143
Comments
@sindresorhus all of the validation currently happens inside of yargs (https://github.com/yargs/yargs/blob/master/lib/validation.js). Challenges to implementing this feature in
I think this could be a really interesting task for someone. |
refreshing myself with how we handle other strings, we do already have support for translations in yargs-parser, which is good: var __ = opts.__ || function (str) {
return util.format.apply(util, Array.prototype.slice.call(arguments))
} |
Give the errors a unique |
@sindresorhus I was about to reply; since this is a development time error, not a user-land error, I wonder fi we could get away with a throw in this one case, even though we're not throwing for any other errors currently in the parser. |
Yes, throwing would be the correct thing to do here. It's a developer-error, not a end-user error. Throw early. |
@sindresorhus, @juergba has been starting to add some more early validation checks in |
see: #301 |
If it doesn't cost too much effort, would you mind to keep an option to coerce the values as it was in previous versions of the module? An example use case is to save the user's default in the |
The parser should not allow setting the incorrect type for
default
.The above should not be allowed as we defined
foo
as a number, but thedefault
is set to a string. This should throw an error to prevent mistakes.The text was updated successfully, but these errors were encountered: