export default ({ values, keys, allRequired }) => {
  values = Array.isArray(values) ? values : [values];

  return values.reduce((acc, cur) => {
    const valuesKeys = Object.keys(cur);
    const isValid = allRequired ? test(keys, valuesKeys) : test(valuesKeys, keys);
    return isValid && acc;
  }, true);
};

const test = (validator, validate) => validator.every(el => validate.includes(el));
