Skip to content
Latchkey

cue vet: Validate Data Against a CUE Schema

cue vet schema.cue data.yaml checks that the data satisfies the CUE schema and constraints, failing on any conflict.

CUE is a typed configuration language whose vet command validates concrete data against a schema, catching type mismatches and constraint violations in CI.

What it does

cue vet unifies the given data files with a CUE schema and reports any conflicts: wrong types, out-of-range values, missing required fields, or disallowed extra fields. Because CUE unifies rather than merely checks, a value that contradicts a constraint fails. It exits non-zero on any error.

Common usage

Terminal
# validate YAML data against a CUE schema
cue vet schema.cue data.yaml

# validate against a specific definition
cue vet -d '#Config' schema.cue config.yaml

# validate JSON piped in
cat config.json | cue vet schema.cue -

# be strict about incomplete/extra fields
cue vet -c schema.cue data.yaml

Options

FlagWhat it does
-d <expr>Definition/expression to validate against, e.g. #Config
-c, --concreteRequire all fields to be concrete (fail on incomplete)
--strictTreat additional constraints strictly
-E, --all-errorsPrint all errors, not just the first
--schema <name>Explicit schema value in the instance

In CI

cue vet exits non-zero when data conflicts with the schema, so it is a drop-in gate for config validation. Add -c so incomplete config (a required field left unset) also fails, and -E to surface every problem in one run instead of one at a time.

Common errors in CI

data.yaml: field not allowed: extraKey means the schema is closed and the data has an unknown field. conflicting values "prod" and string (mismatched types int and string) flags a type conflict. port: invalid value 70000 (out of bound <=65535) reports a constraint violation. #Config.name: incomplete value string (with -c) means a required field is missing. some instances are incomplete; use the -c flag hints you need --concrete.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →