本页内容
Sommatic 文档
打开控制台

Validators

对值的检查。

以 Markdown 查看
在以下应用中打开

每个示例都在已部署的表达式引擎上、基于页面末尾的示例上下文运行过。

$isEmpty

$isEmpty(value)

当 value 没有可枚举的自有键时返回 true:{}、[]、''、null 和 undefined。它检查的是键而非内容:只看第一层({ a: {} } 不为空),并且对没有键的数字和布尔值返回 true。

参数

value any 必填
通常是对象或列表。

返回

boolean 没有自有键时为 true。

示例

{{ $isEmpty($json.query) }}
结果 boolean
true
{{ $isEmpty($json.body.items) }}
结果 boolean
false

未执行的节点输出为空。

{{ $isEmpty($('Approval').item.json) }}
结果 boolean
true

数字没有键:结果为 true。

{{ $isEmpty(5) }}
结果 boolean
true

说明

  • 对于缺失或为空的字段,$ifEmpty 更易读。切勿对数字或布尔值使用 $isEmpty。

在 JSONata 中 $$isEmpty(query)

示例上下文

示例基于以下数据运行:当前节点的输入($json)、已运行的节点($(…))、本次运行的 ID 以及当前节点。时钟固定为 2026-11-26T14:30:00.000Z,服务器时区为 UTC,因此各页面中 $now 与 $today 的值都相同。

当前节点的输入 JSON
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "[email protected]",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  }
}
已运行的节点(标签 → 输出) JSON
{
  "Webhook Receiver": "= $json",
  "Normalize input": {
    "correlation_id": "c-7f3a",
    "channel": "web"
  },
  "Classify": {
    "label": "billing",
    "confidence": 0.92
  }
}
运行与当前节点 JSON
{
  "$execution": {
    "id": "fir-xxxx",
    "flow_instance_id": "fi-xxxx",
    "flow_definition_id": "fd-xxxx",
    "flow_version_id": "fv-xxxx",
    "flow_slug": "order-intake"
  },
  "$node": {
    "id": "node-notify",
    "label": "Notify customer"
  }
}

示例运行所基于的编排器提交 31e874b

安装智能体工具

为你的编程智能体接入 Sommatic AI 官方文档:技能包、文档 MCP 服务器与 Markdown 页面,无需再抓取网页。

仅安装技能包,不会自动更新;需要时重新运行即可。

npx skills add https://docs.sommatic.ai
智能体如何读取本文档