Skip to content

Commit

Permalink
fix: edge cases, duplication, log output (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartosz Leoniak authored and simondel committed Sep 13, 2019
1 parent ee19f5a commit 7f42d34
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/core/src/config/ConfigValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ export default class ConfigValidator {
}

private validateThresholdValue(name: keyof MutationScoreThresholds, value: number | null) {
if (typeof value === 'number' && (value < 0 || value > 100)) {
if (typeof value === 'number' && (value < 0 || value > 100 || isNaN(value))) {
this.invalidate(`Value "${value}" is invalid for \`thresholds.${name}\`. Expected a number between 0 and 100`);
}
}

private validateThresholdsValueExists(name: keyof MutationScoreThresholds, value: number | undefined) {
private validateThresholdsValueExists(name: keyof MutationScoreThresholds, value: any) {
if (typeof value !== 'number') {
this.invalidate(`Value "${value}" is invalid for \`thresholds.${name}\`. Expected a number between 0 and 100`);
}
Expand All @@ -77,7 +77,7 @@ export default class ConfigValidator {
const logLevel = this.options[logProperty];
const VALID_LOG_LEVEL_VALUES = [LogLevel.Fatal, LogLevel.Error, LogLevel.Warning, LogLevel.Information, LogLevel.Debug, LogLevel.Trace, LogLevel.Off];
if (VALID_LOG_LEVEL_VALUES.indexOf(logLevel) < 0) {
this.invalidate(`Value "${logLevel}" is invalid for \`logLevel\`. Expected one of the following: ${this.joinQuotedList(VALID_LOG_LEVEL_VALUES)}`);
this.invalidate(`Value "${logLevel}" is invalid for \`${logProperty}\`. Expected one of the following: ${this.joinQuotedList(VALID_LOG_LEVEL_VALUES)}`);
}
}

Expand Down

0 comments on commit 7f42d34

Please sign in to comment.