Function validateStrList

Returns an array of strings from the given list while validating each one using the checkFn function.

If it returns without throwing, the input is necessarily valid. If the result is an empty array, it will return null.

LisnUsageError If the input is not a string or array of strings, or if any entries do not pass checkFn.

  • Type Parameters

    • T extends string = string

    Parameters

    • key: string

      Used in the error message thrown

    • value: unknown
    • OptionalcheckFn: (value: string) => value is T

    Returns undefined | T[]

    undefined if the input contains no non-empty values (after trimming whitespace on left/right from each), otherwise a non-empty array of values.