---
title: "Use validators based on date range"
canonical: "https://support.appfire.com/space/PSJ/15482456/Use%20validators%20based%20on%20date%20range"
format: markdown
---
> Macro (aura-html)


Use the following script as a workflow transition validator. It allows a transition only if the date field value is within 180 days from today.

```
interval range = "180d";
date maxDate = currentDate() + range;

string errorMsg = "Due date must be within 180 days of today";

if(isNull(due) || due > maxDate) {
    return false, "error", errorMsg;
}
```