Make Regex usable in Decision Split - Mendix Forum

Make Regex usable in Decision Split

5

In Mendix, we can define Regexes just like we do Microflows and Constants. However, unlike Constants, these Regexes can only be used in validation rules within the domain model, and not in decision splits inside microflows.

 

image.png

 

It would be extremely helpful to allow the use of defined Regexes directly in decision splits within validation microflows, not just in the domain model validation.

 

Right now, I have to manually write expressions like isMatch($UserEmail, '\w+((-|\+|\.)\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+') in every decision split that needs it. If I improve my regex, I have to manually update every instance across my application.

 

The Regex definition already exists in Mendix; extending its usability to microflows would save a lot of effort and reduce errors.

 

Would it be possible to add this feature?

 

 

 

 

 

asked
4 answers

And it's a good workaround haha, I'm going to use it!

Created

Oh yeah, my comment was more meant as a workaround, i still think your suggestion is a good one :)

Created

I somewhat agree. By following your steps, you do end up with a reusable rule for validating, for instance, an email address.

 

However, if, for some reason, you also use validation rules on your entity that check for an email address, you can't reuse this rule—only the regular expression itself. And now you have two places where you need to maintain the expression.

 

image.png

 

To me, it doesn’t make sense that Mendix allows you to store regular expressions, but only lets you use them in validation rules, even though they could be useful in many other areas as well.

 

image.png

Created

Maybe i understand you wrong, but you can make a new rule, in that rule you have a String parameter as input, then you make a decision split that checks the input, and put the ismatch string in the decision. You exit the rule with a true/false boolean.

 

After that you can use this same rule at every decision split in every microflow  that needs it?

Created