X: [1, 2, 4]#X: {for x in X {"\(x)": x }}#MustHave: [3]#Xcheck: #X & {for x in #MustHave {"\(x)": x}}
cue eval check-basic.cue
#Xcheck: field not allowed: "3":
./check-basic.cue:3:5
./check-basic.cue:4:2
./check-basic.cue:4:13
./check-basic.cue:11:10
./check-basic.cue:11:15
./check-basic.cue:11:17
./check-basic.cue:11:38
这个例子用于演示 struct 类型的 list:
check-struct.cue
X: [{ name: "a" val: 1}, { name: "b" val: 2}, { name: "c" val: 3}]#X: {for x in X {"\(x.name)": x }}#MustHave: ["b"]#Xcheck: #X & {for x in #MustHave {"\(x)": _}}