diff --git a/common/issues/issues.js b/common/issues/issues.js index 08413b7a..4e2dc61a 100644 --- a/common/issues/issues.js +++ b/common/issues/issues.js @@ -80,6 +80,15 @@ export class Issue { this.generateMessage() } + /** + * Whether this issue is an error. + * + * @returns {boolean} + */ + isError() { + return this.level === 'error' + } + /** * Override of {@link Object.prototype.toString}. * @@ -118,8 +127,14 @@ export class Issue { this.message = `${this.level.toUpperCase()}: [${this.hedCode}] ${message} (${hedSpecLink}.)` } + /** + * Return a tuple with a boolean denoting overall validity and all issues. + * + * @param {Issue[]} issues A list of issues. + * @returns {[boolean, Issue[]]} Whether the validation succeeded (i.e. any errors were found), and all issues (both errors and warnings). + */ static issueListWithValidStatus(issues) { - return [!issues.some((issue) => issue.level === 'error'), issues] + return [!issues.some((issue) => issue.isError()), issues] } }