Skip to content
Snippets Groups Projects
Commit 194b5b4b authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix: Config validation ignore null and massage schedule to array (#558)

parent 055cfaf7
No related branches found
No related tags found
No related merge requests found
......@@ -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',
......
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment