It Should Help

Date Verifier Reference

Created by should().date(entry: Date | string | null | undefined) — a Date instance or an ISO string; both are normalized before any check.

Type

type DateAccuracy = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';

Methods

Method

Passes when

equals(expected: Date \| string, accuracy?: DateAccuracy)

both dates, truncated to accuracy (default 'millisecond'), have the same time

before(then: Date \| string)

entry < then (exclusive)

after(then: Date \| string)

entry > then (exclusive)

inRange(min: Date \| string, max: Date \| string)

min < entry < max (both exclusive)

Plus the inherited not and defined().

Representative messages

  • `${real} does not equal ${expected}.` (equals)

  • `${real} is not before ${then}.`/`${real} is not after ${then}.`

  • `${real} isn't in range [${min}, ${max}].` (inRange)

Accuracy semantics

Truncation drops the smaller units from both sides before comparing:

  • 'day' — compares year/month/day only;

  • 'month' — compares year/month;

  • 'year' — compares the year;

  • 'hour'/'minute'/'second' — keep time down to the named unit;

  • 'millisecond' (default) — exact comparison.

Unparseable strings become an Invalid Date instead of null — the definedness guard does not catch them (Caveats).

Guide: Dates.

02 сентября 2026