fix: implies should not fail when implied key's value is 0, false or empty string#1985
Merged
bcoe merged 3 commits intoyargs:masterfrom Jul 28, 2021
Merged
Conversation
Member
|
@mathieubergeron thanks for the contribution 👍 will make an effort to give review soon. |
Member
|
@jly36963 if you happen to beat me to code review, at a glance this contribution looked solid to me 😄 |
jly36963
reviewed
Jul 15, 2021
Contributor
|
@bcoe I tested it locally with and without his changes, his fix works. |
jly36963
approved these changes
Jul 25, 2021
bcoe
approved these changes
Jul 28, 2021
This was referenced Nov 25, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an attemps at fixing #1091 and #1203.
The issue
The documentation for
impliesis:But this check fails when the value of the key
yis0,false, or empty string.When
yvalue isfalse, we might wantimpliesto continue failing though. I'd like to have your input on that, and I will adjust that PR accordingly.The issue came from
keyExistswhich, instead of always returning a boolean, could returned the value of the key. That value is later on used like so:Thus, that
ifresolved totruewhenvaluewas0,falseor"".The fix
Having
keyExistsalways returning a boolean seems more robust. I usedObject.hasOwnPropertyto check for presence of the key instead.Let me know if you think that
keyExistsshould still returnfalsewhen the value of the key isfalse.Thanks :)