Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Writing validator in JMWE to validate label containing at least one entry starting with a string

Ola Nissen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 30, 2021

Hi,

I've tried to search for a post but can't find one that matches. I would like to have a JMWE validator that makes sure that on the issue that I'm trying to transition, there is at least one (there may be several) labels that start with a certain string. No labels at all are not accepted.

Let's pretend that I have the requirement to have at least one label starting with "US-" - so "US-FL", or "US-TE" e.g.

So no label would give an error, one label saying "CA-OT" would not be OK but having two labels saying "CA-OT" and another "US-WY" would be OK as would having "US-AL" and "US-NY".

1 answer

1 accepted

1 vote
Answer accepted
David Fischer
Community Champion
November 30, 2021

Hi @Ola Nissen ,

this is the Jira Expression you need for your Build-your-own Validator:

!!issue.labels && issue.labels.some(label => label.indexOf("US-") == 0)

 Regards,

David

Ola Nissen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 30, 2021

Thanks for the quick answer. Tested and verified. Excellent help.

Suggest an answer

Log in or Sign up to answer