github.com/solo-io/cue@v0.4.7/doc/tutorial/basics/2_types/60_disjunctions.txt (about)

     1  cue eval disjunctions.cue
     2  cmp stdout expect-stdout-cue
     3  
     4  -- frontmatter.toml --
     5  title = "Disjunctions"
     6  description = ""
     7  
     8  -- text.md --
     9  Disjunctions, or sum types, define a new type that is one of several things.
    10  
    11  In the example, our `Conn` definition of earlier is augmented to define
    12  the possible values for `protocol`: `"tcp"` or `"udp"`.
    13  It is an error for a concrete `Conn`
    14  to define anything else than these two values.
    15  
    16  -- disjunctions.cue --
    17  #Conn: {
    18      address:  string
    19      port:     int
    20      protocol: "tcp" | "udp"
    21  }
    22  
    23  lossy: #Conn & {
    24      address:  "1.2.3.4"
    25      port:     8888
    26      protocol: "udp"
    27  }
    28  
    29  -- expect-stdout-cue --
    30  #Conn: {
    31      address:  string
    32      port:     int
    33      protocol: "tcp" | "udp"
    34  }
    35  lossy: {
    36      address:  "1.2.3.4"
    37      port:     8888
    38      protocol: "udp"
    39  }