The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Validator to restrict spaces on custom field text

Jason Galea
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 Champions.
August 13, 2018

Hi,

 

I am trying to set up a validator on issue creation using "ScriptRunner for JIRA" to only allow a field to be filled in only if there are no 'Spaces'

Example: 

abc 123 < Incorrect

abc123 < Correct

 

Any suggestions please? 

Cheers,
Jason

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Bastian Stehmann
Community Champion
August 13, 2018

Hi @Jason Galea,

 

it should work if you get the field value as string and then check, for example with the contains-method, if there are any spaces within.

Roland Holban (Adaptavist)
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 Champions.
August 13, 2018

Use this as your validator condition:

!cfValues["FIELD_NAME"]?.value.contains(" ") 
Jason Galea
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 Champions.
August 27, 2018

It works. Thanks a lot @Roland Holban (Adaptavist)