Skip to content

if-not-empty

if-not-empty - check if a value has content (is not empty)

state-name:
tool: if-not-empty
arguments:
value: <expression>
goto:
true: <has-content-state>
false: <empty-state>

The if-not-empty tool is the negated version of if-empty. It returns "true" if the value has content, or "false" if it is empty, whitespace-only, or null.

A value is considered “not empty” if it:

  • Contains non-whitespace characters
  • Is not the literal string "null"
  • Is not null

This tool is useful when the positive case (having content) is the expected path.

ArgumentRequiredDefaultDescription
valueYes-The value to check for content
CodeMeaning
0Success (outputs “true” or “false”)
1Missing required argument

The tool outputs "true" if the value has content, or "false" if it is empty.

validate-input:
tool: if-not-empty
arguments:
value: "{{ user_input }}"
goto:
true: process-input
false: prompt-for-input
read-config:
tool: bash
arguments:
command: cat config.yaml 2>/dev/null || echo ""
output: var(config_content)
next: check-config
check-config:
tool: if-not-empty
arguments:
value: "{{ config_content }}"
goto:
true: parse-config
false: create-default-config
call-api:
tool: bash
arguments:
command: 'curl -s https://api.example.com/data | jq -r ".result"'
output: var(api_result)
next: check-result
check-result:
tool: if-not-empty
arguments:
value: "{{ api_result }}"
goto:
true: use-result
false: handle-empty-response
check-token:
tool: if-not-empty
arguments:
value: "{{ auth_token }}"
goto:
true: authenticated-flow
false: login-required
ensure-value:
tool: if-not-empty
arguments:
value: "{{ critical_value }}"
goto:
true: continue-workflow
false: abort-with-error
check-changes:
tool: bash
arguments:
command: git diff --name-only
output: var(changed_files)
next: has-changes
has-changes:
tool: if-not-empty
arguments:
value: "{{ changed_files }}"
goto:
true: process-changes
false: nothing-to-do
  • if-empty - Check if value is empty
  • if-equal - String equality comparison
  • switch - General conditional branching