Field with only 5 digit value

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2018

As I have Number field with XXX name and I want user should enter a value only 5 digits in between 0-9 (no less than 5 or more than 5). I tried the regular expression validator but here Number field takes the values in a decimal point and the regular expression validator not working with this Number field.

Using the same validator i tried with new YYY text field and its working as expected but the data of XXX number field will be a loss if I use this YYY text filed.

Any help will be appreciated.

2 answers

1 accepted

0 votes
Answer accepted
Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2018

As i mentioned in my above comment i have worked on a script validator to check if the provided value should be greater than 9999 and less than or equal to 99999 and this script is working fine as expected.

1 vote
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 8, 2018

What plugin to Jira are you using to gain this regex validator? I don't believe that Jira natively has this kind of validator available in Jira Server workflows.  If this is Jira Cloud please let me know, it's possible there are different built in workflow validators on that platform. I am curious to see how this might work with Jira.

Another concern is what regex did you try to use?

I thought that a regex of

[0-9]{5}

might work, but then I realized that there are two problems here:

  1. Jira's number custom field both allows for floating points (decimals)
  2. AND if you try to start a number with one or more zeroes '0', these get dropped from number fields.   So normally in Jira, inputting a value of 01234 will get saved as 1234.  

But I think this still might be possible to setup in jira with the right validator, but the other concern is in regards to which screens this field appears on.  

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 8, 2018

HI @Andy Heinzer

Thanks for your response.

We are using in-house jira software and Yes, this kind of workflow validator is not available by default. we are using script runner, JSU add-on so this workflow validator belong to any one of these add-ons.

We have created a Number field called XXX and now we want that user should provide only 5 digit value while creating jira issue so here I used regular expression workflow validator ie [0-9]{5} but the thing here is the Number field stores values as a decimal point so while creating user is providing the 5 digit value only let say 12345 but this regex validator takes as a 12345.0 because of this reason the regular expression workflow validator is not working.

What I did is I wrote a custom script validator to check the value range ie the value should be greater than 9999 and less than 99999, so now its working fine as expected.

Please let me know if this is correct what I did or not, if not then let me know the correct way and how to achieve this without a script or any other option.

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 11, 2018

That solution looks fine to me.  I was thinking of the possibility to tweak the regex to accept other optional qualifiers, such as to access a .0 on the end since it doesn't affect the integer value.   I had also been exploring the possibility to see if there was a plugin that could create a different custom field, of type integer, however I did not find this yet.

Yogesh Mude
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 12, 2018

HI @Andy Heinzer

Thanks for your response.

Yes, we need to think how the regex will work with Number custom field.

Suggest an answer

Log in or Sign up to answer