all files / src/ isValid.js

100% Statements 10/10
100% Branches 10/10
100% Functions 3/3
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 493×   490× 34×   456×    
export default function isValid(error) {
  if (Array.isArray(error)) {
    return error.reduce((valid, errorValue) => valid && isValid(errorValue), true);
  }
  if (error && typeof error === 'object') {
    return Object.keys(error).reduce((valid, key) => valid && isValid(error[key]), true);
  }
  return !error;
}