Validators check that any input available to the transition (such as user-supplied input) is valid before the transition is performed. If a transition's validator 'fails', the transition's post functions will not be executed and the issue will not progress to the destination step of the transition.
You can use JJupin and SIL to define a large set of validators beside the default validators offered by Jira, by just adding a (k) SIL Validator to a transition and publishing the workflow, as described here.
Below are just a few common examples:
Required plugins
Comment required
A validator that forces users to enter a comment during a transition, otherwise displaying a customized error message:
string errorMsg = "You must enter a comment!"; if(!hasInput("comment")) { return false, "comment", errorMsg; }
Field has single value
A SIL validator for checking if a multi-valued field does not contain more than one value during a transition:
string errorMsg = "You must choose a single fix version!"; if(size(fixVersions) > 1) { return false, "fixVersions", errorMsg; }
Parent status
A SIL validator which ensures that the current issue's parent issue is in one of the specified Statuses:
string[] statuses = {"Opened", "Reopened"}; string errorMsg = "Parent issue should have status Opened or Reopened!"; if(!isNull(parent) && !elementExists(statuses, parent.status)) { return false, errorMsg; }