Validators are just like conditions in that they return a true or false value. If TRUE, the user is allowed to compete the transition. If FALSE, the user will not be allowed to complete the transition. However, unlike conditions, a message will be displayed telling the user why they were unable to complete the transition.
Example 1 - Issue must have subtasks
string errorMsg = "Issue must have subtasks!"; if(size(subtasks(key)) == 0) { return false, errorMsg; }
Example 2 - Must be a comment in the transition screen
Because the second parameter (optional) was used in this example the error message will also display beneath the comment field. When using transition screens be sure to use routines that can read screen values like hasInput() or getInput() otherwise the script will retrieve the value (if any) stored in the issues and not the value the user just input into the field and is trying to save.string errorMsg = "You must enter a comment!";
if(!hasInput("comment")) {
return false, "comment", errorMsg;
}