JS Utils Kit - v0.5.1
    Preparing search index...

    Function isNonEmptyString

    • Determines whether the given value is a non-empty string.

      This function first checks if the input is a string using isString. If it is not a string, the function returns false. If it is a string, it then checks whether the string contains any non-empty content.

      By default, the function trims the string before checking its length, which means strings containing only whitespace (e.g., " ") will be considered empty. This behavior can be controlled using the trim parameter.

      Type Parameters

      • T

        The type of the value being checked.

      Parameters

      • value: T

        The value to validate as a non-empty string.

      • trim: boolean = true

        Whether to trim whitespace from the string before checking its length. Defaults to true.

      Returns boolean

      • A boolean indicating whether the input is a non-empty string.
      isNonEmptyString('hello'); // true
      isNonEmptyString(' '); // false (trim is true by default)
      isNonEmptyString(' ', false); // true (whitespace is counted)
      isNonEmptyString(123); // false
      isNonEmptyString(null); // false