@metreeca/blue - v0.12.0
    Preparing search index...

    Function union

    • Creates a union shape.

      Alternatives are accepted as they are stated: a union that exists proves nothing about the distinguishability of its branches, which is a modelling contract settled when a value is matched. An alternative that is itself a union contributes the alternatives it holds rather than nesting, so that a union of unions reads as the single flat list of alternatives it admits values from.

      Type Parameters

      • B extends readonly [Lazy<Shape>, ...Lazy<Shape>[]]

        The alternatives a value may be drawn from

      Parameters

      • ...branches: B

        The shapes a value may be drawn from, each possibly deferred to break definition cycles

      Returns UnionShape<B>

      An immutable shape admitting the values any of the branches admits

      const location = optional(union(
      string(),
      reference(PostalAddress)
      ));