This Commented CUE
demonstrates how to use the
built-in
function
or()
to create a
disjunction
from a list.
example.cue
package example
source: ["a", "b", "c"]
// result is assigned "a" | "b" | "c"
result: or(source)
// each field in "test" must adhere to the
// constraints of the "result" disjunction
test: [string]: result
test: {
one: "a"
two: "b"
three: "c"
four: "X" // invalid value
}
TERMINAL
$ cue vet .:example
test.four: 3 errors in empty disjunction:
test.four: conflicting values "a" and "X":
./example.cue:3:10
./example.cue:10:17
./example.cue:15:9
test.four: conflicting values "b" and "X":
./example.cue:3:15
./example.cue:10:17
./example.cue:15:9
test.four: conflicting values "c" and "X":
./example.cue:3:20
./example.cue:10:17
./example.cue:15:9