next: Order is irrelevant


Constraints specify what values are allowed. To CUE they are just values like anything else, but conceptually they can be explained as something in between types and concrete values.

Constraints can be used to validate values of concrete instances. They can be applied to CUE data, or directly to YAML or JSON.

But constraints can also reduce boilerplate. If a constraints defines a concrete value, there is no need to specify it in values to which this constraint applies.


Language :: {
	tag:  string
	name: =~"^\\p{Lu}" // Must start with an uppercase letter.
languages: [...Language]


  - tag: en
    name: English
  - tag: nl
    name: dutch
  - tag: no
    name: Norwegian

$ cue vet schema.cue data.yaml

languages.2.tag: conflicting values string and false (mismatched types string and bool):
    ./schema.cue:2:8 invalid value "dutch" (does not match =~"^\\p{Lu}"):