Skip to content

Date Validators

Date elements support a range of validators to enforce date constraints. Validators are added to the element's validators array.

Available validators

Validator Description
dateAfter Date must be on or after a specified date. Use value: "todaysDate" for a dynamic today comparison.
dateAfterControl Date must be on or after another field's date value (use value: "fieldKey").
dateAfterAndNotOnControl Date must be strictly after another field's date (not equal to it).
dateBefore Date must be on or before a specified date.
dateBeforeControl Date must be on or before another field's date value.
dateBeforeWarning Shows a warning (not a blocking error) if the date is before a specified date. The form remains valid.

Configuration

Add validators to the validators array of a date-input element:

{
  "key": "inceptionDate",
  "label": "Inception Date",
  "type": "date-input",
  "validators": [
    {
      "validator": "dateAfter",
      "message": "Inception date cannot be in the past",
      "value": "todaysDate"
    }
  ]
}

Examples

Date must be today or later

{
  "validator": "dateAfter",
  "message": "Cannot be earlier than today",
  "value": "todaysDate"
}

Expiry date must be after inception date

{
  "validator": "dateAfterControl",
  "message": "Expiry date must be after the inception date",
  "value": "inceptionDate"
}

Date must be strictly after (not on) another date

{
  "validator": "dateAfterAndNotOnControl",
  "message": "Must be strictly after the start date",
  "value": "startDate"
}

Warning if date is before a fixed date

{
  "validator": "dateBeforeWarning",
  "message": "This date appears to be earlier than expected — please confirm",
  "value": "2025-01-01T00:00:00Z"
}

Error vs warning

dateBeforeWarning is the only validator that produces a warning rather than a blocking error. Use it when you want to alert the user without preventing form submission — for example, flagging an unusually early inception date that may be a typo, but not blocking it.

All other date validators produce blocking errors: the user cannot submit the form until the constraint is satisfied.

Notes

  • value: "todaysDate" is a special keyword recognised by Workbench. All other values should either be a fieldKey (for cross-field comparisons) or an ISO 8601 date string (for fixed date comparisons).
  • The message field is shown to the user when the validation fails. Write it in plain English and make it clear what the user needs to do.
  • Multiple validators can be applied to the same date field by adding multiple entries to the validators array.