Function validateOr

  • Validate an input with a fallback

    Type Parameters

    • T

      The validated type

    Parameters

    • validator: Validator<T>

      The validator to use

    • fallback: T

      The fallback

    Returns ((input) => T)

      • (input): T
      • Parameters

        • input: unknown

        Returns T

    Example

    validateOr(isNumber, 0)(1) >> 1;
    validateOr(isNumber, 0)("1") >> 0;