What is the server-side formatter to check if a string exists in an array of strings?

What is the server-side formatter to check if a string exists in an array of strings?

["abc", "xyz"]

How do I check if "xyz" exists in that array?

At first I thought I would use the "Contains" formatter, but the description of it makes me think it's for "string in string", not "string in array of strings"

I think you are correct on the formatter. I use the array actions now and the contains action does what you need.

Interesting, it seems there's some magic here, .contains() is a formatter for strings, but "contains" is also implemented as a module function for the array Wappler component. This means I would have to use .contains exactly as in the screenshot, I couldn't e.g. use a Set Value with .contains() to check an array

I think the correct use is actually inArray()
It doesnt seem to be fully documented although these posts may help understand it.

and

inArray formatter will be added to Server Connect in the next update. Contains will also be updated to work with arrays and not only with strings.

5 Likes

inArray is now available in Wappler 7.3.6:

Also you can now use contains with arrays as well: