So I currently have a custom attributes where I need to check parameters if not equals to the set attribute but I want the condition to be case insensitive. And it seems like using != operator doesn't work that way.
I have this on the Flow:
<Step> <Name>EntityError</Name><Condition>(verifyapikey.Verify-API-Key.attr != "All") and (verifyapikey.Verify-API-Key.attr != params.entity) </Condition> </Step>
Solved! Go to Solution.
You can use a JS policy before this step and then set a variable like "invalidAttr = true"; after validating your use case and use this variable check the condition in the next step.
Something like this:
const attribute = context.getVariable('verifyapikey.Verify-API-Key.attr') || ''; const invalidAttr = attribute.toLowerCase() !== "all" && attribute !== params.entity ? true : false; context.setVariable('invalidAttr', invalidAttr);
<Step> <Name>EntityError</Name> <Condition>invalidAttr</Condition> </Step>
You can use regular expression matching in conditions.
<Condition>NOT (verifyapikey.Verify-API-Key.attr ~~ "(?i)All") and (verifyapikey.Verify-API-Key.attr != params.entity) </Condition>
This expression : "(?i)All"
... is a regex that matches any form of "all" , case-insensitively.
You can use a JS policy before this step and then set a variable like "invalidAttr = true"; after validating your use case and use this variable check the condition in the next step.
Something like this:
const attribute = context.getVariable('verifyapikey.Verify-API-Key.attr') || ''; const invalidAttr = attribute.toLowerCase() !== "all" && attribute !== params.entity ? true : false; context.setVariable('invalidAttr', invalidAttr);
<Step> <Name>EntityError</Name> <Condition>invalidAttr</Condition> </Step>
FYI. You cannot use const in the JS callout in Apigee. The basic idea is fine.
Thanks! It works on my scenario and it gave me more idea on how to manipulate other data.
Glad to hear that!
<Condition><your_variable> EqualsCaseInsensitive "text2compare"</Condition> should work
Yes, that is true, per the documentation. Be aware, there is a small bug, internal reference b/165009601, which causes EqualsCaseInsensitive
to not work properly when you have a star (asterisk) in your text.
<!-- OK - will always return correct results -->
<Condition>my_variable EqualsCaseInsensitive "foobar"</Condition>
<!-- NOT OK - will sometimes get it wrong -->
<Condition>my_variable EqualsCaseInsensitive "foobar*"</Condition>
In the latter case, EqualsCaseInsensitive
should match if and only if the my_variable
contains "foobar*" , or something case-insensitively equivalent (FooBar*, fooBar*, fooBAR*, etc). In an EqualsCaseInsensitive
test, the asterisk is documented to be just a character. But in actual behavior, EqualsCaseInsensitive
treats the asterisk as a glob-like pattern indicator meaning "zero or more other characters". As an example of the incorrect behavior, EqualsCaseInsensitive
will return true if my_variable
contains '"foobar" or "fooBar-anything-else". This is incorrect, and surprising. A fix is in the backlog.
To avoid the problem
You can use regular expression matching in conditions.
<Condition>NOT (verifyapikey.Verify-API-Key.attr ~~ "(?i)All") and (verifyapikey.Verify-API-Key.attr != params.entity) </Condition>
This expression : "(?i)All"
... is a regex that matches any form of "all" , case-insensitively.
Hi Thanks, It works but on the params.entity(the attr and params.entity, should also be case insensitive)
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |