minDate
The date is not earlier than the given one.
Signature
ts
function minDate(date: Date | string | number | (() => Date), msg?: Message): Action<Date>Parameters
| Parameter | Type | Description |
|---|---|---|
date | Date | string | number | (() => Date) | A date or a function returning it — the function is called on every validation |
msg | Message | Custom error message |
Error codes
| Code | When | Default message |
|---|---|---|
minDate | The date is earlier | Must be on or after {date} |
You can change the texts: see Messages & i18n.
Notes
Works with date and coerce.date. In the message {date} is the date as YYYY-MM-DD.
Example
A booking not in the past
ts
const checkIn = pipe(coerce.date(), minDate(() => new Date()));