# Multiple validation rule

Hi friends,
I am getting confused with writing my syntax for validation rules in a single select question. It is described below:

Q1 - GroupSize (Here the validation is: self >= 2) - That one is OK
Q2 - Group description
Code. Description
1…Couple with children
2…Couple without children
3…Friends
4…Associates
5…School group
6…Tour group
7…Other

The validation should be like below.
1…If self == 1 then group size need to be greater or equal to 3
2…If self == 2 then (GroupSize%2) ==0
3…If self.InList(5,6) then group size need to be greater of equal to 10

I have made several trial to write these validation but without success.

Can anyone help. Thank you

Hi friends,
I’m back. I used the following validation and it seems to work.

1. self == 1 && GroupSize >= 3 || self.IsNoneOf(1) && GroupSize >= 2;

2. self.InList(2) && (GroupSize % 2) == 0 || self.IsNoneOf(2) && (GroupSize % 2) >= 0;

3. self.InList(5,6) && GroupSize >= 10 || self.IsNoneOf(5,6) && GroupSize >= 2;

If anybody can simplify these three for me, it would be of great help. Thank you.

Hi Jean,

Based on your specification of the 3 validations another way to do it would be using the conditional operator:

1. self==1 ? GroupSize>=3 : true
2. self==2 ? GroupSize%2 == 0 : true
3. self.InList(5,6) ? GroupSize>=10 : true

Klaus

2 Likes

Hi Klaus,
Tutor and saviour.
Thank you. Short but sweet. I didn’t thought of the conditional operator and you help me foresee future validations using it.
Thanks.

Can be wrapped to a single condition:

(self==1 && GroupSize>=3) || (self==2 && GroupSize % 2==0) || (self.InList(5,6) && GroupSize>=10) || !self.InList(1,2,5,6)

Best, Sergiy

Hi Sergiy,