Function validateEachOr

  • Validate an array of inputs 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

    validateEachOr(isNumber, 0)([1, 2, 3]) >> [1, 2, 3];
    validateEachOr(isNumber, 0)(["1", 2, "3"]) >> [0, 2, 0];