Grouping conditional validation rules in InfoPath

I’m a kind of contradictional developer. I want to do as much in SharePoint without having to write code. There is a lot you can do before you need to call a (often hard to find and expensive) SharePoint developer.

Last I needed to modify an existing InfoPath form. They needed a simple conditional rule to validate an entry in the form. A first sight this seemed to be an easy job but then I noticed that InfoPath does not accept grouped conditions in the validation rules.

I needed something like this:

A field is invalid when:

(Field A = “valueA” OR Field B = “valueB”) AND Field C is blank

When you build this in InfoPath you can only do this:

But I needed this:

I found this clever workaround:

I used and expression with the contains function. The expression checks if the keyword (a concatenation of possible values, like “valueAvalueB”) contains the selected value in the field. With this solution I do not need to group my conditions anymore.