-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Description
Hey, I spotted strange behaviour when using keys with dots which is inconsistent and can crash validating config.
See example below:
const config = convict({
test: {
param: {
doc: 'some nested parameter',
format: String,
default: 'foo',
},
},
});
// Example 1
config.load({ 'test.param': 'bar' });
config.validate({ allowed: 'strict' }); // passes validation
console.log(config.get('test.param')); // prints out 'foo' - unexpected, since previous load should set the value or fail validation
// in this example the validate would throw an error, key with dot should not be treated as path
// Example 2
config.load({ 'someOther.param': 'baz' });
config.validate({ allowed: 'warn' }); // throws error - unexpected, should just print a warning
/* the error:
Uncaught Error: cannot find configuration param 'someOther.param'
at walk ([...]/node_modules/convict/src/main.js:2:8321)
at flatten ([...]/node_modules/convict/src/main.js:2:1400)
at validate ([...]/node_modules/convict/src/main.js:2:2099)
at Object.validate (/[...]/node_modules/convict/src/main.js:2:10481)
*/
I'm using convict in version 6.2.4 and node v18.17.0.
kalinkrustev and c-cal
Metadata
Metadata
Assignees
Labels
No labels