Skip to content

Commit

Permalink
Simplify inputSet validation
Browse files Browse the repository at this point in the history
  • Loading branch information
M1kep committed May 31, 2022
1 parent 46e94b8 commit a1d704e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions main.js
Expand Up @@ -44,13 +44,9 @@ async function main() {
}
]
uniqueInputSets.forEach((inputSet) => {
const occurrences = Object.values(inputSet).reduce((occurrences, val) => {
if (val !== '') {
occurrences++
}
return occurrences
},0)
if(occurrences > 1) {
const inputs = Object.values(inputSet)
const providedInputs = inputs.filter(input => input !== '')
if (providedInputs.length > 1) {
throw new Error(`The following inputs cannot be used together: ${Object.keys(inputSet).join(", ")}`)
}
})
Expand Down

0 comments on commit a1d704e

Please sign in to comment.