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 Leaders.
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

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 Leaders.
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 Leaders.
August 27, 2018

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

Suggest an answer

Log in or Sign up to answer