Function assertEachWith

  • Asserts that all items pass the assertion. This function can be used to constrain a type from T[] to Constrained[].

    Type Parameters

    • T

      the type of each input item.

    • Constrained

      the constrained type of each input item.

    Parameters

    • items: T[]

      The array of items to inspect.

    • assertion: (item: T) => asserts item is Constrained

      The assertion function. If all items pass, the array itself will be constrained too.

    • Optionalmessage: string

      Optional message to include if an assertion fails.

    Returns asserts items is Constrained[]

    an aggregate error with all failures, rather than just the first one encountered.