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

Conflicting regex not working

Srinath S July 20, 2021

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

0 votes
Answer accepted
Alex Medved _ConfiForms_
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.
July 20, 2021

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

Srinath S July 20, 2021

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?

Alex Medved _ConfiForms_
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.
July 20, 2021

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

Srinath S July 25, 2021

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

Atlassian Community Events