hapipal / confidence

Dynamic, declarative configurations
Other
264 stars 44 forks source link

Using 0 as default for coerce number returns undefined #115

Closed jlimas closed 2 years ago

jlimas commented 2 years ago

As the title says, using 0 as the $default value for a $coerce number returns undefined.

Example key in store.

messages: {
    delay: {
        $env: 'MESSAGES__DELAY',
        $coerce: 'number',
        $default: 0,
    }
}

The test case

it('should coerce values to number', () => {
    expect(store.get('/messages/delay')).toBe(0)
})

image

Using any other value for $default like 1 makes the test pass without problems.

Nargonath commented 2 years ago

Thank you for your report. This looks like a bug to me.

jlimas commented 2 years ago

I think I found the issue, I created a PR @Nargonath not sure if I'm missing something but I think that's the root cause.

devinivy commented 2 years ago

Fix from #116 published in v6.0.2, thanks again!

Nargonath commented 2 years ago

Thanks for the quick fix @jlimas.