Function ensureSet

  • Assert that a value is set and throw a MissingValueError if it is not, i.e., both null and undefined values will throw an error. This can be nice to use when transforming data between view model and rest api model.

    Type Parameters

    • T

    Parameters

    • value: undefined | null | T

      the value asserted to be set.

    • message: string = ""

      an optional exception message to use if the check fails.

    Returns T | never

    the value unambiguously defined.

    MissingValueError if value is not set.