Операторы условий
Операторы сравнения
Равно (eq)
{ "condition": { "operator": "eq", "left": { "contextPath": "status" }, "right": "ready" }}Работает со строками, числами, булевыми значениями.
Не равно (neq)
{ "condition": { "operator": "neq", "left": { "contextPath": "error_count" }, "right": 0 }}Больше (gt)
{ "condition": { "operator": "gt", "left": { "contextPath": "score" }, "right": 80 }}Больше или равно (gte)
{ "condition": { "operator": "gte", "left": { "contextPath": "items_count" }, "right": 1 }}Меньше (lt)
{ "condition": { "operator": "lt", "left": { "contextPath": "retry_count" }, "right": 3 }}Меньше или равно (lte)
{ "condition": { "operator": "lte", "left": { "contextPath": "error_rate" }, "right": 0.05 }}Строковые операторы
Содержит (contains)
{ "condition": { "operator": "contains", "left": { "contextPath": "message" }, "right": "error" }}Также работает с массивами:
{ "condition": { "operator": "contains", "left": { "contextPath": "tags" }, "right": "urgent" }}Операторы существования
Существует (exists)
{ "condition": { "operator": "exists", "operand": { "contextPath": "optional_field" } }}Возвращает true, если переменная существует и не равна null/undefined.
Пусто (isEmpty)
{ "condition": { "operator": "isEmpty", "operand": { "contextPath": "items" } }}Возвращает true для:
- Пустой строки
"" - Пустого массива
[] - Null/undefined
Логические операторы
И (and)
Все условия должны быть истинными:
{ "condition": { "operator": "and", "conditions": [ { "operator": "eq", "left": { "contextPath": "status" }, "right": "complete" }, { "operator": "gt", "left": { "contextPath": "score" }, "right": 80 } ] }}ИЛИ (or)
Хотя бы одно условие должно быть истинным:
{ "condition": { "operator": "or", "conditions": [ { "operator": "eq", "left": { "contextPath": "priority" }, "right": "high" }, { "operator": "eq", "left": { "contextPath": "priority" }, "right": "critical" } ] }}НЕ (not)
Инвертирует условие:
{ "condition": { "operator": "not", "condition": { "operator": "eq", "left": { "contextPath": "status" }, "right": "blocked" } }}Синтаксис путей контекста
Простой путь
{ "contextPath": "variable_name" }Вложенный путь
{ "contextPath": "user.profile.name" }Индекс массива
{ "contextPath": "items[0]" }Комбинированный
{ "contextPath": "results[0].score" }Литеральные значения
Значения правой части могут быть литералами:
{ "right": "string value"}{ "right": 42}{ "right": true}{ "right": null}При сравнении с contextPath на обеих сторонах оба значения разрешаются из контекста перед
сравнением.
Типичные паттерны
Проверка булевого флага
{ "condition": { "operator": "eq", "left": { "contextPath": "has_tests" }, "right": "yes" }}Проверка лимита итераций
{ "condition": { "operator": "lt", "left": { "contextPath": "current_iteration" }, "right": 5 }}Проверка непустого результата
{ "condition": { "operator": "and", "conditions": [ { "operator": "exists", "operand": { "contextPath": "result" } }, { "operator": "not", "condition": { "operator": "isEmpty", "operand": { "contextPath": "result" } } } ] }}Смотрите также
- Шаблоны Workflows - Использование условий в workflows
- Валидация - Правила валидации входных данных