put validation on field

0
i have input field  i want to put the validation so that user will not able to fill emoji
asked
3 answers
0

Hi Rachana,

you can add validation on the page,microflow and in domain model

 

Refer the below documentation 

https://docs.mendix.com/refguide/setting-up-data-validation/

 

Also, check the below forum link

https://forum.mendix.com/link/space/security/questions/116129

answered
0

Hi Rachana,

I’d suggest validating user input using a Regex. You can either whitelist allowed symbols or blacklist disallowed symbols. The most failsafe method is probably to whitelist all characters that you allow in your input field. 

answered
0

Hi Rachana,

 

You will need to make a microflow for this validation.

For example, you press save and the microflow checks via a Regex if there isn't an emoji in the string. If not, then you commit the object and show the next screen. If there is, you can show a validation message and end the flow. You can use this Regex: 

 

/^(?:(?![\p{Emoji}]).)*$/
 

Explanation:

  • ^ asserts the start of the string.
  • (?:(?![\p{Emoji}]).)* is a non-capturing group that matches any character as long as it is not an emoji character. [\p{Emoji}] matches any emoji character using the Unicode property \p{Emoji}.
  • .* matches any number of characters.
  • $ asserts the end of the string.

 

Or this: 

 

/^[\p{L}\p{N}\p{P}\s]+$/

 

Explanation:

  • ^ asserts the start of the string.
  • [\p{L}\p{N}\p{P}\s] matches any Unicode letter (\p{L}), number (\p{N}), punctuation (\p{P}), or whitespace (\s) character.
  • + allows one or more occurrences of the previous character set.
  • $ asserts the end of the string.

 

I have not tested these XPath's so make sure to do so yourself.

answered