Validate the schema to require defaults
Default values are required for every config key. If a default value is not set, convict does not throw a validation error.
If there are any missing default keys, config.validate() should throw a validation error.
This just bit us, when doing config.get('value'), the configuration object was returned { doc: 'Some documentation', format: '*', env: 'TEST_VALUE' }. This stopped happening when we set default.
On 4.4.1, when I have no default configured for a value, eg..
var convict = require("convict")
var config = convict({
something: {
format: (val) => { /* noop */ },
env: "SOMETHING"
}
});
config.validate({ allowed: 'strict' });
The error I get is..
Error: something.format: should be of type Function: value was {}
Which is neither correct (format is a function..?) or at all helpful.
var convict = require("convict") var config = convict({ something: { format: (val) => { /* noop */ }, env: "SOMETHING" } }); config.validate({ allowed: 'strict' });
Convict understands :
{
"something": {
"format": {
"format": "function"
},
"env": {
"default": "SOMETHING",
"format": "string"
}
}
}
Default values are required for every config key. If a default value is not set, convict does not throw a validation error.
We can't do that because :
https://github.com/mozilla/node-convict/blob/d2637632ee2a8c05905e15f2ca9000b6ef2dde21/lib/convict.js#L241-L245
Or we should disable the magic normalizer when we use the strict mode.