This Commented CUE demonstrates how to use the built-in function or() to create a disjunction from a list.

This allows the list to be used as a constraint that only permits values that are present in the list.

example.cue
package example

source: ["a", "b", "c"]
result: or(source)

// Each field in "test" must have a value that
// unifies successfully with a value in "source".
test: [string]: result
test: {
	one:   "a"
	two:   "b"
	three: "c"
	four:  "XYZ" // invalid value
}
TERMINAL
$ cue eval -i .:example
source: ["a", "b", "c"]
result: "a" | "b" | "c"
test: {
    one:   "a"
    two:   "b"
    three: "c"
    four:  _|_ // test.four: 3 errors in empty disjunction: (and 3 more errors)
}