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

Evaluate if $default is defined instead of using it as a boolean #116

Merged
merged 1 commit into from
Feb 21, 2022
Merged

Evaluate if $default is defined instead of using it as a boolean #116

merged 1 commit into from
Feb 21, 2022

Conversation

jlimas
Copy link
Contributor

@jlimas jlimas commented Feb 21, 2022

No description provided.

@devinivy
Copy link
Member

Thanks for the contribution! Could you add a test to ensure we're fixing the case you described in #115?

@devinivy devinivy added the bug label Feb 21, 2022
@jlimas
Copy link
Contributor Author

jlimas commented Feb 21, 2022

Hello @devinivy ! I did add a test case specifically for the issue I was having in #115

The test case below without the fix was returning undefined since it was evaluating if node.$default and since 0 evaluates to false it was assuming the node didn't have a $default property. I just changed the code to check if the variable is defined instead.

key12: {
    zero: {
        $env: 'ZERO',
        $coerce: 'number',
        $default: 0
    }
},

get('/key12', { zero: 0 }, {}, [], {});
get('/key12', { zero: 1000 }, {}, [], { ZERO: '1000' });

@devinivy
Copy link
Member

Oh apologies, not sure how I missed that! Thanks 👍

@devinivy devinivy self-assigned this Feb 21, 2022
@devinivy devinivy added this to the 6.0.2 milestone Feb 21, 2022
@jlimas
Copy link
Contributor Author

jlimas commented Feb 21, 2022

No worries, really happy to help, I'm a big fan of this library.

@devinivy
Copy link
Member

Resolves #115

@devinivy devinivy merged commit 76ddf13 into hapipal:master Feb 21, 2022
@Nargonath
Copy link
Member

Thanks @devinivy for the publish and @jlimas for the quick fix. 💪

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

Successfully merging this pull request may close these issues.

3 participants