Field input validation to check for max chars between the pre filled field value

Lakshmi S
Contributor
March 7, 2024

Hi Team,

We have a custom field called the "Desired Product Account name" field with a single-line text box (The field should take "alpha numeric"). I need the validation to check for max chars (maximum is 20 chars between "AWS" and the environment of nonprod/prod)

Example :  aws |[Text box with 20 Max chars]| nonprod/prod


 It needs to be clear that we will prepend "aws" to the front of the requested name, and "nonprod" and "prod" to the end of the names
sample :  awsexamplenonprod  , awssampleprod, etc
Is there any possibility with script runner or JMWE addons ?

2 answers

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.
March 7, 2024

Hi @Lakshmi S 

You can use a JMWE Scripted Validator with code like this:

issue.get("Desired Product Account name")?.toLowerCase() ==~ /^aws\w{1,20}(prod)|(nonprod)$/
Lakshmi S
Contributor
March 8, 2024

Hi @David Fischer ,

How to prefilled the these values in the field ?

aws and nonprod/prod ? the validation for in between those 20 chars max. Should i add default value of that to the field ?

aws |[Text box with 20 Max chars]| nonprod/prod

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.
March 9, 2024

Not sure how you can pre-fill the value - I guess you could have a default value showing the "template" for the value. But the validator will only validate that the value entered in the field is correct: it starts with aws, it ends with either prod or nonprod, and in-between is 1 to 20 alphanumeric characters.

Alternatively, you could use a post-function to automatically add "aws" and "prod" or "nonprod" to the value that's input in the field by the user, and have the user only input the 1 to 20 characters in-between.

Lakshmi S
Contributor
March 14, 2024

Thank you @David Fischer . The JMWE script validation is perfectly working, and the post function suggested by you for pre-fill value.

0 votes
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 7, 2024

Hi @Lakshmi S scriptrunner could handle this with a custom scripted validator you could probably even put it into a screen behaviour and address the validation before the end user hits submit(create/update) on the issue.

Suggest an answer

Log in or Sign up to answer