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

Ola Nissen 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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 November 30, 2021

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

Suggest an answer

Log in or Sign up to answer