swc/crates/swc_bundler/tests/.cache/deno/351ef37dc999e80ad3e8964c74224cf42355d15b.ts
2021-11-09 20:42:49 +09:00

23 lines
701 B
TypeScript

// Loaded from https://deno.land/x/validasaur/src/rules/date_between.ts
import type { Validity, Rule } from "../types.ts";
import { clearTimes, dateChecks } from "../utils.ts";
export function dateBetween(minDate: Date, maxDate: Date): Rule {
return function dateBetweenRule(value: any): Validity {
return dateChecks(
value,
"dateBetween",
{ minDate, maxDate },
(input: Date): boolean => {
const inputDateTime = clearTimes(input).getTime();
const minDateTime = clearTimes(minDate).getTime();
const maxDateTime = clearTimes(maxDate).getTime();
return inputDateTime >= minDateTime && inputDateTime <= maxDateTime;
},
);
};
}