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

    Function cardinality

    • Creates a SetFactory with custom cardinality constraints.

      Returns a SetFactory that wraps a shape into a SetShape with the specified bounds. A Dictionary model is projected per tag within its language map; every other multi-valued model is held as a singleton [element] tuple, the collection form of the Query grammar. A retrieval Selection is supplied per request in the template, never declared on the shape.

      Type Parameters

      • L extends number | undefined

        The minimum count constraint type

      • U extends number | undefined = undefined

        The maximum count constraint type

      Parameters

      • lower: L

        Minimum number of expected values

      • Optionalupper: U

        Maximum number of expected values

      Returns SetFactory<L, U>

      An immutable SetFactory with the specified cardinality bounds

      TypeError If lower or upper is negative, or if lower exceeds upper

      const twoToFive = cardinality(2, 5);
      const tags = twoToFive(string());
      const items = cardinality(0, 100)(resource(ItemShape));