idea-toolbox
    Preparing search index...

    Function isEmpty

    • Check if a field (/variable) is empty or invalid, based on its type. If the type isn't passed as a parameter, it will be auto-detected.

      A field is "empty" when it carries no usable value; the check is intentionally fail-closed: when in doubt (wrong runtime type, unexpected exception) it returns true. The supported fieldType values:

      • string: not a string, or only whitespace.
      • number: not a finite number (NaN/±Infinity/non-numbers included), or 0.
      • positiveNumber: not a finite number, or <= 0.
      • integer: not an integer, or 0.
      • positiveInteger: not an integer, or <= 0.
      • boolean: not a boolean — both true and false are valid, non-empty values.
      • object: an empty array/Set/plain object, or an invalid Date.
      • date: not a strict, calendar-valid YYYY-MM-DD string (see ISODateString).
      • datetime: not a complete ISO 8601 date-time string (see ISOString); a date-only string such as 2026-05-22 is considered empty here — use date for that.
      • email / phone / url / domain: not a string, or not valid for the format.

      Parameters

      • field: any

        the field to check

      • OptionalfieldType: isEmptyFieldTypes

        set to force a type check

      Returns boolean

      return if the field is empty/invalid or not