node-convict
node-convict copied to clipboard
Incorrect validation
If i define type like:
logging: {
file: {
doc: 'Settings for file logging',
format: '*',
default: false,
}
},
}
And then in conf.json set object to logging.file
"logging": {
"file": {
"path": "/logs/",
"maxSize": 10485760,
"maxFiles": 30,
"level": "debug"
}
}
because you in validation you check default value in scheme, but when i set '*' any format, i can have any type of value. Also format can be set as function and types of allow values can be different too.
default should be {} and format: 'Object' also you can make your own format to allow false or an Object.
var convict = require('convict');
var conf = convict({
logging: {
file: {
doc: 'Settings for file logging',
format: 'Object',
default: {}
}
}
});
conf.load({
"logging": {
"file": {
"path": "/logs/",
"maxSize": 10485760,
"maxFiles": 30,
"level": "debug"
}
}
});
conf.validate();
console.log(conf.getProperties())
This issue should be closed because is author error.