1 answer

0 votes

No, because the order of validators does not matter.

Each validator is a simple yes or no question. If any one of them is a "no", the whole thing fails.

Think of baking a cake - you have validators like "do we have eggs", "do we have flour", and "do we have sugar" and "do we have butter".  If any of them are "no", the transition from "gathering ingredients" to "making cake" fails.  It is irrelevant what order you check for them.

I suspect your question is about a conditional flow of validation - if <something> = X, then check Y, but if <something> = Z, then do no further checks.  Is that what you're trying to do?

I just want to have the same order as the fields in the screen. I can add a new field in the beginning of the screen but the new validation will be executed as the last one.

I just want to have the same order as the fields in the screen. I can add a new field in the beginning of the screen but the new validation will be executed as the last one.

But the order does not matter.  The only place you see the order is when you're an admin editing the workflow.

Assume you have many fields: first field, second field, third field.... When a user fills the form to create the issue and there are validation errors, he will have the alerts to fix the validation errors in the order that are the validations. So the validation for the 10th field may be before the validation of the first field.

Ok, that's a good reason for it, but JIRA doesn't think that way, it just fails all validation without order, because in most cases, it doesn't matter.

You could remove all the validators and re-add them in field order, but there is a better solution.

Write your own validation script to replace the set of canned ones you're using now.  You can check every field you want to in one script, and return an error to the user listing all the fields they've missed or got wrong in one go.  That's better for the user too - if they've made five mistakes, they don't have to correct them one at a time.

Do I have to use Custom script validator for my own validation script insted of Simple scripted validator ? Where can I find an example?

Yes, that's correct.

The snippet I use as a base checks that a value is set if the issue type is bug:

if (issue.issueTypeObject.name == 'Bug' & cfValues['DemoSelectList']?.value == 'Capital'){
        throw new InvalidInputException("Something to tell a user what went wrong")
    return false
}
return true

Hi again!

This is my snippet. I get an error for "InvalidInputException". Do I have to do some imports?

// Import Regex
import java.util.regex.*;
// Construct The Pattern to Match on
Pattern pattern = Pattern.compile("^([0-9]{1,6})\$");
// Check if the Order Number Field is a match

if (cfValues['Order Number'] == null || pattern.matcher(issue.getCustomFieldValue(customFieldManager.getCustomFieldObjectByName("Order Number")))){
throw new InvalidInputException("Please enter a valid number!")
return false
}
return true

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

22,017 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you