Checking if a value matches with a regular expression in microflow

3
I want to check in a custom save microflow if a attribute matches (or not) with a regular expression. Applying a validation rule on meta model level is not a option because I don't want to do the check all the time. This brings me to a general question: what if I have two objects: an employee and a customer. If the employee edits a customer I don't want to require the employee to fill in all fields. So I can't do validation on meta model level. But when the customer edits it's information he have to match the regular expressions. So I try to make a custom save button to check if the information applied by the user matches with the regular expression, but that seems to be impossible. On a input field I can only give a required message. I can't specify maximum length e.t.c. Idea's?
asked
1 answers
3

There is no way to do this in the microflow itself but you can call a simple java action that you pass the regular expression and the string to be verified. You could define this regular expression in the project constants.

This is the code:

Pattern pattern = Pattern.compile(regexString);
Matcher matcher = pattern.matcher(stringToValidate);
boolean isValid = matcher.matches();

Or the short version for a java action returning the boolean:

return Pattern.matches(regexString, stringToValidate);
answered