UNPKG

react-day-picker

Version:

Customizable Date Picker for React

65 lines 2.08 kB
/** * Checks if the given value is of type {@link DateInterval}. * * @param matcher - The value to check. * @returns `true` if the value is a {@link DateInterval}, otherwise `false`. * @group Utilities */ export function isDateInterval(matcher) { return Boolean(matcher && typeof matcher === "object" && "before" in matcher && "after" in matcher); } /** * Checks if the given value is of type {@link DateRange}. * * @param value - The value to check. * @returns `true` if the value is a {@link DateRange}, otherwise `false`. * @group Utilities */ export function isDateRange(value) { return Boolean(value && typeof value === "object" && "from" in value); } /** * Checks if the given value is of type {@link DateAfter}. * * @param value - The value to check. * @returns `true` if the value is a {@link DateAfter}, otherwise `false`. * @group Utilities */ export function isDateAfterType(value) { return Boolean(value && typeof value === "object" && "after" in value); } /** * Checks if the given value is of type {@link DateBefore}. * * @param value - The value to check. * @returns `true` if the value is a {@link DateBefore}, otherwise `false`. * @group Utilities */ export function isDateBeforeType(value) { return Boolean(value && typeof value === "object" && "before" in value); } /** * Checks if the given value is of type {@link DayOfWeek}. * * @param value - The value to check. * @returns `true` if the value is a {@link DayOfWeek}, otherwise `false`. * @group Utilities */ export function isDayOfWeekType(value) { return Boolean(value && typeof value === "object" && "dayOfWeek" in value); } /** * Checks if the given value is an array of valid dates. * * @private * @param value - The value to check. * @param dateLib - The date utility library instance. * @returns `true` if the value is an array of valid dates, otherwise `false`. */ export function isDatesArray(value, dateLib) { return Array.isArray(value) && value.every(dateLib.isDate); } //# sourceMappingURL=typeguards.js.map