adds check for globalConfigs before attempting to loop

This commit is contained in:
Jarrod Flesch
2020-02-25 21:44:00 -05:00
parent 5a6630652a
commit 8ce80be2ee

View File

@@ -1,12 +1,14 @@
const { MissingGlobalLabel, DuplicateGlobalLabel } = require('../errors');
module.exports = function validateGlobal(globalConfigs, Globals) {
Object.values(globalConfigs).forEach((config) => {
if (!config.label) {
throw new MissingGlobalLabel(config);
}
if (Globals && Globals[config.label]) {
throw new DuplicateGlobalLabel(config);
}
});
if (globalConfigs) {
Object.values(globalConfigs).forEach((config) => {
if (!config.label) {
throw new MissingGlobalLabel(config);
}
if (Globals && Globals[config.label]) {
throw new DuplicateGlobalLabel(config);
}
});
}
};