Constraints can be used to validate values of concrete instances. They can be applied to data from any source, whether held in CUE, YAML, JSON, or elsewhere.

Here, a constraint is applied to all the languages stored in data.yml, and is validated using the cue vet command.

#Language: {
	// Name must start with a uppercase
	// letter, as defined by Unicode.
	Name: =~"^\\p{Lu}"
	Tag:  string
languages: [...#Language]
  - Name: English
    Tag: en
  - Name: dutch
    Tag: nl
  - Name: Norwegian
    Tag: "no"
$ cue vet file.cue data.yaml
languages.1.Name: invalid value "dutch" (out of bound =~"^\\p{Lu}"):