Checking if a some value exists across many arrays which are selected as input. #446
-
Hello! I have a data structure which is a map of arrays.
I get an input which is an array of possible keys from the map. I have a final data structure which contains an array of strings, which may or may not, exist under the keys.
The rule I'm looking to write should return true if So for this example, the rule would return true, because I'm new to Rego and not sure how I should structure this. I considered performing Any ideas that could point me in the right direction? Much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi @avo-sepp 👋 There are many ways to do that, but here's an example: https://play.openpolicyagent.org/p/CHr9VZ9fa7 package play
import future.keywords.contains
import future.keywords.if
import future.keywords.in
map := {"key1": ["string1", "string2"], "key2": ["string3", "string4"], "key3": ["string1", "string3"]}
matches contains match if {
some key in input.keyInput
some match in map[key]
match in data.stringValues
}
|
Beta Was this translation helpful? Give feedback.
Hi @avo-sepp 👋 There are many ways to do that, but here's an example: https://play.openpolicyagent.org/p/CHr9VZ9fa7