Function validateString

Returns a valid string from the supplied value, ensuring the supplied value is a string that conforms to the given checkFn.

LisnUsageError If the value is invalid.

  • Type Parameters

    • T extends string = string

    Parameters

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

      If given and the supplied value is a string, then it is called with the value as a single argument. It must return true if the value is valid and false otherwise. If it is not given, then any literal string is accepted.

    Returns undefined | T

    undefined if the input is nullish.