Skip to content

Commit

Permalink
#1666: refactoring & code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Sep 3, 2024
1 parent da09ce5 commit f37a9b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/metadataTypes/MetadataType.js
Original file line number Diff line number Diff line change
Expand Up @@ -2786,23 +2786,25 @@ class MetadataType {
}
}

// get default and custom validation rules
const definition = this.definition;
const validations = await validationsRules(this.definition, item, targetDir);
const validationRules = await validationsRules(this.definition, item, targetDir);

for (const rule of Object.keys(validations)) {
// run validation rules
for (const rule of Object.keys(validationRules)) {
if (
validationConfig[rule] &&
validationConfig[rule] !== 'off' &&
!this.definition.skipValidation?.[rule] &&
!(await validations[rule].passed())
!(await validationRules[rule].passed())
) {
if (validationConfig[rule] === 'error') {
throw new Error(validations[rule].failedMsg);
throw new Error(validationRules[rule].failedMsg);
} else if (validationConfig[rule] === 'warn') {
Util.logger.warn(
` - ${this.definition.type} ${item[this.definition.nameField]} (${
item[this.definition.keyField]
}): ${validations[rule].failedMsg}`
}): ${validationRules[rule].failedMsg}`
);
}
}
Expand Down

0 comments on commit f37a9b9

Please sign in to comment.