In CUE, schemas are typically written as definitions. A definition is a field whose identifier starts with # or _#.

Because CUE knows that definitions are used for validation, they aren’t output as data. It’s normal for definitions to specify fields that don’t have concrete values, such as types.

A definition also tells CUE the complete set of allowed fields, meaning that evaluations will fail if any additional fields are specified. We say that such a definition defines a closed struct. Including a ... in a struct keeps it open.

#Conn: {
	address:  string
	port:     int
	protocol: string

	// Uncomment this to allow any field.
	// ...

lossy: #Conn & {
	address:  ""
	port:     8888
	protocol: "udp"

	// The timeout field is not specified in
	// #Conn, and its presence causes an
	// evaluation failure.
	timeout: 30
$ cue export file.cue
lossy.timeout: field not allowed: