Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Conflicting regex not working

I am facing a very weird issue with regex in my confiform. I am a beginner of Regex.

 

I have a text field in my confiform where I have put a rule below in the field definition's validation field itself to accept only two email ids and below is the rule which works fine and block if more than two email ids are entered:

^(?=[^@]*(?:@[^@]*){0,2}$).*$

In addition I was asked to enter a rule on the same field that only certain domains should be allowed so I inserted a new validation rule macro on this field separately within the form with below  to say that apart from these two domains don't allow anything else:

^.+?(@abc.com|@xyz.com)$

Both of them works independently well but when I have both rules in place(one within the field definition and one as a separate rule definition macro)below is happening:

1. When some one enters some other domain(apart from the two I have configured) and three email ids, the error shows first is the one to say that there are more than two email ids and once I removed the third email id, the domain rule doesn't work

2. If I have only two email ids and if one of them is external domain then domain rule works and throws error stating there is an external domain as expected

 

Kindly help me on how I can combine and get both of them worked fine

1 answer

1 accepted

Hi

This is really not a ConfiForms issue and to get your regular expressions working you can use something like https://regex101.com/

If a regular expression works on that site it will also work in ConfiForms

Alex

Hi Alex,

I tried various regex but nothing that work on the site is working on confiform.

I am now trying to have a multi user field to allow members to select user ids and putting a entry.user.email to pick the email id of the user. I am having a requirement now where I should restrict the number of users selected is to just 2 users. Is that possible?

Could you share the examples of what is working on a site and doe snot work in ConfiForms?

Not sure I understand the part about multi-user field - how is this connected to regexps?

I guess it is not... To check the number of selected users in a field you can use an asCount https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions and https://wiki.vertuna.com/display/CONFIFORMS/ConfiForms+Field+Definition+Rules#ConfiFormsFieldDefinitionRules-Validationrule

Setting the condition to be something like

mymultiuserfield.asCount:>2

And then put the parameter value in the "Message to show when validation fails"

Alex

You are an awesome person here Alex. Almost every solution for a complex problem comes from your. Your suggestion worked like a charm

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

🏑 Atlympic Event: Confluence

Hello Community!  Quick disclaimer: We are running a contest on Community (The Atlympics!) from July 23rd - August 8th of 2021. If you are interested in participating in this contest (prizes! ...

196 views 6 8
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you