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

    Type Alias SetShape<S, L, U>

    Shape for a cardinality-constrained value set.

    Pairs a Shape with minCount / maxCount constraints that bound the expected number of values. Cardinality factory functions (required, optional, repeatable, and multiple) produce instances with pre-set bounds; use cardinality for custom ranges.

    Usage

    import { required, optional, repeatable, multiple, cardinality } from '@metreeca/blue/value';
    import { string } from '@metreeca/blue/string';
    import { integer } from '@metreeca/blue/number';

    required(string()) // minCount=1, maxCount=1 → exactly one string
    optional(integer()) // minCount=undefined, maxCount=1 → zero or one integer
    repeatable(string()) // minCount=1, maxCount=undefined → one or more strings
    multiple(string()) // minCount=undefined, maxCount=undefined → zero or more strings
    cardinality(2, 5)(string()) // custom range

    Inheritance

    When a ResourceShape extends a parent via extends, each set shape is merged according to the following rules.

    Field Override Rule
    kind Cannot be overridden
    minCount Child ≥ parent, narrowing the minimum cardinality
    maxCount Child ≤ parent, narrowing the maximum cardinality
    shape kind must match; a non-union child may narrow a union parent to one

    Cross-Field Validation

    • merged minCount must be ≤ merged maxCount
    type SetShape<
        S extends Lazy<Shape> = Lazy<Shape>,
        L extends undefined | number = undefined | number,
        U extends undefined | number = undefined | number,
    > = {
        kind: "set";
        model: Bounds<S, L, U>;
        minCount?: L;
        maxCount?: U;
        shape: Shape & { model: State<S> };
    }

    Type Parameters

    • S extends Lazy<Shape> = Lazy<Shape>

      The wrapped shape, eager or a Lazy factory for recursive self-reference

    • L extends undefined | number = undefined | number

      The minCount constraint type

    • U extends undefined | number = undefined | number

      The maxCount constraint type

    Index

    Properties

    kind: "set"

    Discriminator identifying this as a set shape.

    Inheritance — cannot be overridden.

    model: Bounds<S, L, U>

    Prototype value for runtime model assembly.

    Scalar value sets hold the shape model directly; multi-valued sets hold a singleton [element] tuple. Dictionary shapes always hold a single language map because cardinality applies per tag within the map, not to the map itself. The type is unioned with undefined when minCount is 0 or undefined, reflecting the optional arm on the template side. See Bounds for the projection rules.

    Inheritance — computed from shape and cardinality, not user-defined.

    minCount?: L

    Minimum number of expected values.

    Inheritance — child value must be ≥ parent value, narrowing the minimum cardinality.

    undefined (no minimum constraint, equivalent to 0)

    maxCount?: U

    Maximum number of expected values.

    Inheritance — child value must be ≤ parent value, narrowing the maximum cardinality.

    undefined (no maximum constraint)

    shape: Shape & { model: State<S> }

    The constrained value shape, or a union of value shapes for polymorphic values.

    Inheritance — child shape.kind must match parent shape.kind, with one exception: when parent is a union, child may supply a non-union value shape that narrows exactly one parent variant (single-variant narrowing). Otherwise delegated to value shape or union merge rules.