How to validate a text custom field

Jan Kowalski August 31, 2013

Hello :) I am newbe in Jira (5.2) and I would like to add custom field to my screen. I used custom field as text type and I want to allow users to enter in this field only data in the format XX:YY (which will be represented time eg. 21:00, 07:10 ...). I need to control that users can't enter an invalid value eg. 33:45, 88:77 .... How can I do that in Jira? Thanks for your reply.

4 answers

0 votes
Jan Kowalski August 31, 2013

Nic Brough ... I need to find or write a "validator" that will check the input matches the format which I want. As I mentioned Jira is new for me so I thought that maybe there are some options that will allow me in an easy and quick way to do something like this. I see that without the developers can not be done my restrictions.


Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 31, 2013

Correct, there is no validator in the off-the-shelf version that will do what you need. You will need a plugin (or possibly some javascript)

I'd be tempted to try https://marketplace.atlassian.com/plugins/ru.mail.jira.plugins.uniqueregexfield although there are other plugins that might be of help too.

0 votes
Chaithra N
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 31, 2013

We had a similar kind of requirement, we wanted users to enter only emaild IDs in the text field (i.e.., the text must end with "@xxx.com").

So, we had a written a validator which works based on Java Regular Expression (REGEX).

As a Admin while configuring the validator we would choose the CustomField whose value has to be validated and the required regex expression was configured.

Similar kind of validator would be meet your requirement

Note:

Having a custom Field would not be generic, because the Customfield will meet only your current requirement. But Validator can be used in many different ways with Regex expression

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 31, 2013

Just to fully explain that - you need to find or write a "validator" that will check the input matches the format you want to force on that field.

Or you could write a field *type* that encapsulates the function (a bit like the way a date or number field will only accept certain inputs)

Sara is suggesting the second and pointing you to the code you'll need to write

0 votes
Sara ak
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 31, 2013

if you extend GenericTextCFType for you custom field class, just override this method:

public void validateFromParams(CustomFieldParams relevantParams, ErrorCollection errorCollectionToAddTo, FieldConfig config)

Suggest an answer

Log in or Sign up to answer