@mui/x-date-pickers-pro
Version:
The Pro plan edition of the Date and Time Picker components (MUI X).
35 lines (34 loc) • 855 B
JavaScript
import { validateTime } from '@mui/x-date-pickers/validation';
import { isRangeValid } from "../internals/utils/date-utils.js";
import { rangeValueManager } from "../internals/utils/valueManagers.js";
export const validateTimeRange = ({
adapter,
value,
timezone,
props
}) => {
const [start, end] = value;
const dateTimeValidations = [validateTime({
adapter,
value: start,
timezone,
props
}), validateTime({
adapter,
value: end,
timezone,
props
})];
if (dateTimeValidations[0] || dateTimeValidations[1]) {
return dateTimeValidations;
}
// for partial input
if (start === null || end === null) {
return [null, null];
}
if (!isRangeValid(adapter.utils, value)) {
return ['invalidRange', 'invalidRange'];
}
return [null, null];
};
validateTimeRange.valueManager = rangeValueManager;