Skip to content

after ​

The date is later than the date in a sibling field.

Signature ​

ts
function after(field: string, msg?: Message): Action<Date>

Parameters ​

ParameterTypeDescription
fieldstringName of the sibling field
msgMessageCustom error message

Error codes ​

CodeWhenDefault message
afterThe date is not later than the siblingMust 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' }

See also ​