TOC Prev Next

Expressions

Conditional Fields

Field comprehensions can also be used to add a single field conditionally.

Converting the resulting configuration to JSON results in an error as justification is required yet no concrete value is given.

conditional.cue:

price: number

// Require a justification if price is too high
justification: string if price > 100

price: 200

$ cue eval conditional.cue

price:         200
justification: string