Validation feedback - string behaviour

I'm using the new (brilliant) feature 'add validation feedback' to check for required fields. I'm encountering some problems though, here's the case: I want to check whether a person's name has been filled in. So when the user presses the custom save button that I've made, I use a microflow check 'peron's name != empty. If this returns 'false', then I will add validation feedback by stating 'this is a required field'. When the users enters a value for the person's name, then presses the save button then no validation feedback should be given. So far so good, but when the user first fills in a name, then presses 'save', then empties the name and presses 'save' again, then the check 'person's name != empty returns true... Why is there a difference in result when the user first fills something in that he / she empties later on?
3 answers

Michel, I think the difference is empty as NULL and as no character. You should also check if the string value is '' (no character between the spaces)


If a new object is created all attributes get their default value (configured in the metamodel in the Business Modeler). If no default value is set the attribute will be empty (in Java terms: NULL). So, if your String attribute is required you should check on empty.

However, if you first put a value in an attribute via the AJAX client and afterwards remove that value by emptying the input field, the AJAX client will send "" to the server as value. So, it doesn't send empty (or NULL in programmers terms).

Concluding: if a attribute is required and may neither be empty or "", than you should check in your microflow on attribute != empty && attribute != ""

Addon: For an Integer attribute the AJAX client also sends "" if the input field is emptied. As "" is not a valid Integer value the Integer attribute will be set to empty (NULL for programmers). The reason we send "" is that if the User on purpose empties the field, he or she does not mean 0, so we cannot set the value to 0 (or another valid Integer value).


Note that an string empty check (mystring = '') does not match strings like '<space>' or any strings that are longer than zero characters, including whitespaces. The same holds for the required validation rule, it is satisfied even when a user enter a single space character.

If you want to check if the user really entered some characters, you should add the validation rule regex:

Update (the previous one had troubles with multiline strings):


Note that he {2,} indicates: at least two characters.

De \S might be replaced with \w if you want to enforce the existence of alphanumeric characters.