Skip to content

dateBefore

Matcher for a Date holding an instant earlier than the given one.

Matchers are applied through assertObjectMatches, where they narrow the corresponding property type.

import { assertObjectMatches, dateBefore } from "@kensio/smartass";
const value: unknown = {
createdAt: new Date("2026-01-01T00:00:00.000Z"),
};
assertObjectMatches(value, {
createdAt: dateBefore(new Date("2026-06-01T00:00:00.000Z")),
});
// value is now narrowed to an object with a Date createdAt
// {
// createdAt: Date;
// }

Source file: src/assert/date-before/date-before.match.ts