after
The date is later than the date in a sibling field.
Signature
ts
function after(field: string, msg?: Message): Action<Date>Parameters
| Parameter | Type | Description |
|---|---|---|
field | string | Name of the sibling field |
msg | Message | Custom error message |
Error codes
| Code | When | Default message |
|---|---|---|
after | The date is not later than the sibling | Must be after {field} |
You can change the texts: see Messages & i18n.
Notes
Compared with the raw value of the sibling field — a date or a string. If the sibling is empty or not a date, the rule passes: that field's schema reports the error.
Example
ts
const Period = object({
start: coerce.date(),
end: pipe(coerce.date(), after('start')),
});
validate(Period, { start: '2026-05-10', end: '2026-05-01' }).errors; // { end: 'Must be after start' }