blob: 310e2f655a77e50cf59e10480e06ccea40008c70 [file] [log] [blame]
cue eval defaults.cue
cmp stdout expect-stdout-cue
-- frontmatter.toml --
title = "Default Values"
description = ""
-- text.md --
Elements of a disjunction may be marked as preferred.
If there is only one mark, or the users constraints a field enough such that
only one mark remains, that value is the default value.
In the example, `replicas` defaults to `1`.
In the case of `protocol`, however, there are multiple definitions with
different, mutually incompatible defaults.
In that case, both `"tcp"` and `"udp"` are preferred and one must explicitly
specify either `"tcp"` or `"udp"` as if no marks were given.
-- defaults.cue --
// any positive number, 1 is the default
replicas: uint | *1
// the default value is ambiguous
protocol: *"tcp" | "udp"
protocol: *"udp" | "tcp"
-- expect-stdout-cue --
replicas: 1
protocol: "tcp" | "udp" | *_|_