Function guards

  • Augment a validator to cast an input

    Type Parameters

    • T

      The validated type

    Parameters

    Returns ((input) => input is T)

      • (input): input is T
      • Parameters

        • input: unknown

        Returns input is T

    Example

    if (guards(isNumber)(input)) {
    // input is treated as a number in this block
    }