Hi Experts,
I have a requirement to validate user input using a regex, which doesn’t seem directly feasible in the portal. After exploring recommendations from the community, I implemented the following approach:
Could you please confirm if this approach is reliable?
Additionally, should the API key used to authenticate the Web API be created with the same service account used in the Portal object, or should it be created with a separate service account to ensure a secure design?
++ Mathieu Drouin Mike Schmitt Stefan Helzle Peter Lewis
Please suggest your views on this
Discussion posts and replies are publicly visible
That's the way to go if you need regex. And if your existing service account is specific to your app, I do not see a reason to create another one.
Do you actually need to use regex? I understand that regex has a lot of flexibility, but a lot of validations can be achieved directly through an expression in Appian without needing this extra integration.
Hi Peter,
Here is the expression we used to successfully implement the IP validation, not sure if we can achieve this with nested if logic or not.?
Please suggest.
a!localVariables( local!ipv4regex: "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}$", local!ipv6Regex: "^([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4}$", local!classAip: "^10\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))$", local!classBip: "^172\.(?:1[6-9]|2[0-9]|3[0-1])\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))$", local!classCip: "^192\.168\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))$", local!classAPort: "^10\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))(\_)(6553[0-5]|655[0-2][0-9]|65[0-4][0-9][0-9]|6[0-4][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[0-9])$", local!classBPort: "^172\.(?:1[6-9]|2[0-9]|3[0-1])\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))(\_)(6553[0-5]|655[0-2][0-9]|65[0-4][0-9][0-9]|6[0-4][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[0-9])$", local!classCPort: "^192\.168\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))\.((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([1-9][0-9])|([0-9]))(\_)(6553[0-5]|655[0-2][0-9]|65[0-4][0-9][0-9]|6[0-4][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[0-9])$", local!nat444Regex: "^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.){3}(25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\_)(6553[0-5]|655[0-2][0-9]|65[0-4][0-9][0-9]|6[0-4][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[0-9])$", local!nat64Regex: "^([0-9a-fA-F]{0,4}:){7}[0-9a-fA-F]{0,4}(\_)(6553[0-5]|655[0-2][0-9]|65[0-4][0-9][0-9]|6[0-4][0-9][0-9][0-9]|[1-5][0-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[0-9])$", local!privateIP100: "Some Validation", local!PrivateIP25: "Some Validation", local!Private100Regex: "Some Validation", local!Private25Regax: "Some Validation", if( regexmatch(local!classAip, ri!ipAddress), ri!ipAddress, if( regexmatch(local!classBip, ri!ipAddress), ri!ipAddress, if( regexmatch(local!classCip, ri!ipAddress), ri!ipAddress, if( regexmatch(local!classAPort, ri!ipAddress), ri!ipAddress, if( regexmatch(local!classBPort, ri!ipAddress), ri!ipAddress, if( regexmatch(local!classCPort, ri!ipAddress), ri!ipAddress, if( regexmatch(local!privateIP100, ri!ipAddress), ri!ipAddress, if( regexmatch(local!PrivateIP25, ri!ipAddress), ri!ipAddress, if( regexmatch(local!Private100Regex, ri!ipAddress), ri!ipAddress, if( regexmatch(local!Private25Regax, ri!ipAddress), ri!ipAddress, if( regexmatch(local!ipv4Regex, ri!ipAddress), {}, if( regexmatch(local!nat444Regex, ri!ipAddress), {}, if( and( regexmatch(local!nat64Regex, ri!ipAddress), count(split(ri!ipAddress,"_"))=2, count(split(split(ri!ipAddress,"_")[1],":"))=8, not(rule!CC_isBlank(split(split(ri!ipAddress,"_")[1],":")[8])), not(rule!CC_isBlank(split(split(ri!ipAddress,"_")[1],":")[1])), ), {}, if( and( regexmatch(local!ipv6Regex, ri!ipAddress), count(split(ri!ipAddress,":"))=8, not(rule!CC_isBlank(split(ri!ipAddress,":")[1])), not(rule!CC_isBlank(split(ri!ipAddress,":")[8])) ), {}, ri!ipAddress ) ) ) ) ) ) ) ) ) ) ) ) ) ) )
Ah okay - that's a fairly detailed regex expression. I would guess that it is still possible to do that validation outside of regex in Appian, but probably would involve a very complex Appian expression, so it may not be worth it. I just wanted to verify that it wasn't a basic check that could fairly easily be replicated in Appian so you wouldn't need the full integration.