Skip to content

Commit

Permalink
chore: simplify getMaxSeverity
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Mar 27, 2024
1 parent 2c88d93 commit 8a6a1de
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/lib/components/controls/ValidationErrorsOverview.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,14 @@
expanded = true
}
function getMaxSeverity(errors: ValidationError[]): ValidationSeverity | null {
if (errors.some((e) => e.severity === ValidationSeverity.error)) {
return ValidationSeverity.error
} else if (errors.some((e) => e.severity === ValidationSeverity.warning)) {
return ValidationSeverity.warning
} else if (errors.some((e) => e.severity === ValidationSeverity.info)) {
return ValidationSeverity.info
}
function getMaxSeverity(errors: ValidationError[]): ValidationSeverity | undefined {
const severities = [
ValidationSeverity.error,
ValidationSeverity.warning,
ValidationSeverity.info
]
return null
return severities.find(severity => errors.some((error) => error.severity === severity))
}
</script>

Expand Down

0 comments on commit 8a6a1de

Please sign in to comment.