There are many ways to do it:
import future.keywords.in
violation[{"msg": msg}] {
required:= ["red", "green", "blue"]
input_colors := ["orange", "purple", "blue"]
wrong_colors := [ color | color := input_colors[_]; not (color in cast_set(required)) ]
count(wrong_colors) > 0
msg := sprintf("(%v) not in required colors (%v)", [wrong_colors, required])
}
import future.keywords.in
import future.keywords.every
all_colors_present(input_colors, required_colours) {
every color in input_colors {
color in cast_set(required_colours)
}
}
violation[{"msg": msg}] {
required:= ["red", "green", "blue"]
input_colors := ["r", "green", "blue"]
not all_colors_present(input_colors, required)
msg := "not all colors present!"
}