It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

entry validation

What's the best way to validate the data entry of a text field?

4 answers

what do you want to validate?

the best way is using validators.

check this you can get few validator to validate fields

https://jsutil.atlassian.net/wiki/display/JSUTIL/JIRA+Suite+Utilities+Workflow+Validators

and you can develop your won validator

check this document to know how to develop validators

http://www.j-tricks.com/1/post/2010/08/workflow-validator.html

and even you do this by using script runner plugin

https://jamieechlin.atlassian.net/wiki/display/GRV/Validators

and one more way is using behaviour plugin

https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA+Behaviours+Plugin

I want to validate entry in a free text field and make sure it's in a certain pattern before the input is accept. For example, it must be abc-123, thus start with some letters, then follow by a dash, and a number.

I don't think the JIRA Suite Utilities will do this kind of pattern validation?

Then the only option left is to write my own plugin or do the script runner.

I don't think behaviour plugin will do the job neither. Correct me if I am wrong.

its good idea making your own plugin meeting your requirement.

you write a workflow validator which work only when creation.

now what you need to do is, you get the customfield value from the issue object and try to validate using java Pattern class.

e.g:

Object PackageNumber = issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("Package Number"));

String PackageType =  issue.getCustomFieldValue(cfm.getCustomFieldObjectByName("Package Type")).toString();

if(PackageType.toLowerCase().equals("gca") && Pattern.matches("[0-9]{2}\\.[0-9]{2}\\.[0-9]{2}\\.0{3}$",PackageNumber.toString()) == false)

{	
    CustomFieldManager cfm=ComponentAccessor.getCustomFieldManager();
e.addError(cfm.getCustomFieldObjectByName("Package Number").getId(), "For 'GCA' Build Requests, Package Number must be ##.##.##.000 (i.e., major.minor.maintenance.eFix) where the eFix digits are always 3 zeroes. Moreover, no alpha characters are allowed anywhere in the Package Number. Example 'GCA' Package Numbers include 14.00.00.000 and 14.10.00.000");

    validityFlag = false;
}

if(validityFlag == false)
{	
        		
    e.addError("Field validation failed");
        		
    throw e;
}

Here I'm reading two customfields Package Type and Package Name.If the Package Type is 'GCA', then Package Number should be something like this xx.xx.xx.000

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Calling all Jira Cloud users! Give us feedback on our exploration of a new navigation.

Hi everyone! My name’s Matt and I’m a product manager at Atlassian. I work in the navigation & findability space for all our Jira Cloud products. We’ve been working on trying to improve the exp...

1,051 views 16 12
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you