if-not-empty
if-not-empty - check if a value has content (is not empty)
SYNOPSIS
Section titled “SYNOPSIS”state-name: tool: if-not-empty arguments: value: <expression> goto: true: <has-content-state> false: <empty-state>DESCRIPTION
Section titled “DESCRIPTION”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.
ARGUMENTS
Section titled “ARGUMENTS”| Argument | Required | Default | Description |
|---|---|---|---|
value | Yes | - | The value to check for content |
EXIT CODES
Section titled “EXIT CODES”| Code | Meaning |
|---|---|
0 | Success (outputs “true” or “false”) |
1 | Missing required argument |
OUTPUT
Section titled “OUTPUT”The tool outputs "true" if the value has content, or "false" if it is empty.
EXAMPLES
Section titled “EXAMPLES”Validate User Input
Section titled “Validate User Input”validate-input: tool: if-not-empty arguments: value: "{{ user_input }}" goto: true: process-input false: prompt-for-inputCheck File Exists with Content
Section titled “Check File Exists with Content”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-configVerify API Response
Section titled “Verify API Response”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-responseContinue If Value Present
Section titled “Continue If Value Present”check-token: tool: if-not-empty arguments: value: "{{ auth_token }}" goto: true: authenticated-flow false: login-requiredCOMMON PATTERNS
Section titled “COMMON PATTERNS”Guard Clause
Section titled “Guard Clause”ensure-value: tool: if-not-empty arguments: value: "{{ critical_value }}" goto: true: continue-workflow false: abort-with-errorConditional Processing
Section titled “Conditional Processing”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