Forums

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

validate the value of text field must be numerical and 12 characters long

Nicolas Andika
Contributor
August 20, 2024

Dear All,

i have created a field called Nomor Kontrak (text field type) and i want to create validator in the workflow using a "build your own validator" from JMWEto validate the value must be numerical and 12 characters long,

i have tried my jira expression, but it seems not working, when i already input the correct value, the validator still do not pass, 

my jira expression: 

 

issue.customfield_10057.length == 12 && issue.customfield_10057.match('^[0-9]+$')

what should i fix?

Thankyou

1 answer

1 accepted

0 votes
Answer accepted
Tuncay Senturk
Community Champion
August 24, 2024

Hi @Nicolas Andika 

I didn't notice anything wrong with your statement. Here are a few corrections below.

The match() function returns an array of matches or returns null if there’s no match. This means you should check if the result is not null rather than relying on the function returning true or false.

So, I'd use the below expression, hopefully, it will help.

issue.customfield_10057 != null &&
issue.customfield_10057.length == 12 &&
issue.customfield_10057.match('^[0-9]+') != null

Nicolas Andika
Contributor
August 25, 2024

Hi @Tuncay Senturk 

i have tried your expression and it works, thankyou for the help 

Tuncay Senturk August 26, 2024

Glad it worked :) 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events