packages/material-ui-lab/src/internal/pickers/date-utils.ts/validateDateRange
export const validateDateRange = <TDate>(
  utils: MuiPickersAdapter<TDate>,
  value: RangeInput<TDate>,
  dateValidationProps: DateValidationProps<TDate>,
): [DateRangeValidationErrorValue, DateRangeValidationErrorValue] => {
  const [start, end] = value;

  // for partial input
  if (start === null || end === null) {
    return [null, null];
  }

  const dateValidations = [
    validateDate(utils, start, dateValidationProps),
    validateDate(utils, end, dateValidationProps),
  ] as [DateRangeValidationErrorValue, DateRangeValidationErrorValue];

  if (dateValidations[0] || dateValidations[1]) {
    return dateValidations;
  }

  if (!isRangeValid(utils, [utils.date(start), utils.date(end)])) {
    return ['invalidRange', 'invalidRange'];
  }

  return [null, null];
};