export const isValidIndexWeight = (weightRange, age, weight) => {
  if (
    !Array.isArray(weightRange) ||
    typeof age !== "number" ||
    typeof weight !== "number"
  ) {
    return false;
  }

  const range = weightRange.find((r) => age >= r.fromAge && age <= r.toAge);

  if (!range) return false;

  const maxAllowedWeight = range.toWeight * 1.2;
  return weight >= range.fromWeight && weight <= maxAllowedWeight;
};
