Data validation - Multi Tenant

0
Hello, I have a classic problem of validation like format data. I need to do it per country but in each country it's different. For example, I have a string that behaves differently per country.Germany (DE): Starts with DE, followed by exactly 20 digits.United Kingdom (GB): Starts with GB, followed by 2 digits, then 4 letters, then 14 digits.I need to validate the records per country based on the requirements.How to approach this problem in Mendix in the best way?
asked
1 answers
0

Hello


The isMatch() function requires two parameters: the string to check and the regex string. Based on your requirements, here are the patterns you need:


Germany "DE" + 20 digits '^DE\d{20}$'

United Kingdom "GB" + 2 digits + 4 letters + 14 digits '^GB\d{2}[A-Z]{4}\d{14}$'


I would have 2 attributes in a configuration entity one for the regex pattern and one for the country name.


IN the flow logic I would retrieve the correct validation configuration based on the country I need to validate currently and apply the isMatch() function and pass these attributes and perform the validation this way.


or maybe have 2 entities, one for validation configuration and one for country and properly associate each other


Hope this helps!

answered