This Commented CUE
demonstrates how to use the built-in function
list.UniqueItems
to ensure that a list’s items are unique.
file.cue
package example
import "list"
aList: list.UniqueItems
aList: [1, 2.0, 3, "four", 5, 5.0, false,
{a: 1, b: "2", c: false}, // validation error
{a: 1, b: "2", c: true},
{a: 1, b: 2, c: false},
{a: 1, b: "2", c: false}, // validation error
]
TERMINAL
$ cue vet
aList: invalid value [1,2.0,3,"four",5,5.0,false,{a:1,b:"2",c:false},{a:1,b:"2",c:true},{a:1,b:2,c:false},{a:1,b:"2",c:false}] (does not satisfy list.UniqueItems):
./file.cue:5:8
./file.cue:6:8
Issue #49 tracks the
documentation of precisely what CUE means by values being “equivalent”,
“equal”, or “comparable”. When this documentation is complete it will be linked
to from this guide.
Related content
- The
list
built-in package