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
  • The list built-in package