node-convict icon indicating copy to clipboard operation
node-convict copied to clipboard

Incorrect validation

Open Areks opened this issue 8 years ago • 1 comments

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.

Areks avatar Oct 20 '17 21:10 Areks

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.

A-312 avatar Dec 07 '19 10:12 A-312