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
some instances are incomplete; use the -c flag to show errors or suppress this message
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