I think that if I were to run across this while digging through code, I would be much happier to just see
const validateInput = ({ field1, field2, field3 }) => {
if (!field1) {
return Promise.reject('Missing field1');
}
if (!Array.isArray(field2)) {
return Promise.reject('field2 is not an array');
}
if (!isValidType(field3)) {
return Promise.reject('field3 is invalid');
}
return Promise.resolve();
}
If definitely doesn't win any code golf or cleverness competitions, but it imposes an absolute minimum of cognitive load on someone passing through the code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think that if I were to run across this while digging through code, I would be much happier to just see
If definitely doesn't win any code golf or cleverness competitions, but it imposes an absolute minimum of cognitive load on someone passing through the code.