diff --git a/lib/config/validation.js b/lib/config/validation.js index 7902f36f52f92a73db0de0f5c961c75a3102e7f7..993dc1ee91b8c99d91423d8923d7144bc9bffa7f 100644 --- a/lib/config/validation.js +++ b/lib/config/validation.js @@ -27,7 +27,7 @@ function validateConfig(config) { } for (const key of Object.keys(config)) { - const val = config[key]; + let val = config[key]; if ( !isIgnored(key) && // We need to ignore some reserved keys !isAFunction(val) // Ignore all functions @@ -37,7 +37,7 @@ function validateConfig(config) { depName: 'Configuration Error', message: `Invalid configuration option: \`${key}\``, }); - } else { + } else if (val != null) { const type = optionTypes[key].toString(); if (type === 'boolean') { if (val !== true && val !== false) { @@ -47,6 +47,9 @@ function validateConfig(config) { }); } } else if (type === 'list') { + if (key === 'schedule' && typeof val === 'string') { + val = [val]; + } if (!Array.isArray(val)) { errors.push({ depName: 'Configuration Error', diff --git a/test/config/validation.spec.js b/test/config/validation.spec.js index 03b9854ed7b5664ff79008400b2d6f0adbcf8691..bb5c210fec1725a816c314dd9bbfaf94ac642212 100644 --- a/test/config/validation.spec.js +++ b/test/config/validation.spec.js @@ -5,6 +5,7 @@ describe('config/validation', () => { it('returns nested errors', () => { const config = { foo: 1, + schedule: 'after 5pm', prBody: 'some-body', lockFileMaintenance: { bar: 2, @@ -17,7 +18,7 @@ describe('config/validation', () => { it('errors for all types', () => { const config = { enabled: 1, - schedule: 'after 5pm', + schedule: 5, semanticPrefix: 7, githubAppId: 'none', lockFileMaintenance: false,