if-empty
if-empty - check if a value is empty, whitespace-only, or null
SYNOPSIS
Section titled “SYNOPSIS”state-name: tool: if-empty arguments: value: <expression> goto: true: <empty-state> false: <not-empty-state>DESCRIPTION
Section titled “DESCRIPTION”The if-empty tool evaluates whether a value is considered “empty” and returns "true" or "false" for use with goto branching. This provides cleaner conditional logic compared to using switch with equality expressions.
A value is considered empty if it is:
- An empty string (
"") - Whitespace-only (
" ") - The literal string
"null"(common from JSON extraction) - An actual null value
The value is trimmed before evaluation to handle captured outputs with trailing newlines.
ARGUMENTS
Section titled “ARGUMENTS”| Argument | Required | Default | Description |
|---|---|---|---|
value | Yes | - | The value to check for emptiness |
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 is empty, or "false" if it has content. This output is used for goto routing.
EXAMPLES
Section titled “EXAMPLES”Basic Empty Check
Section titled “Basic Empty Check”check-input: tool: if-empty arguments: value: "{{ user_input }}" goto: true: prompt-for-input false: process-inputCheck Command Output
Section titled “Check Command Output”get-branch: tool: bash arguments: command: git branch --show-current output: var(branch) next: check-branch
check-branch: tool: if-empty arguments: value: "{{ branch }}" goto: true: not-in-repo false: on-branchValidate JSON Field
Section titled “Validate JSON Field”extract-email: tool: bash arguments: command: "jq -r '.email' config.json" output: var(email) next: check-email
check-email: tool: if-empty arguments: value: "{{ email }}" goto: true: email-missing false: email-foundGuard Against Missing Config
Section titled “Guard Against Missing Config”load-api-key: tool: bash arguments: command: 'echo "$API_KEY"' output: var(api_key) next: validate-key
validate-key: tool: if-empty arguments: value: "{{ api_key }}" goto: true: request-api-key false: proceed-with-apiCOMMON PATTERNS
Section titled “COMMON PATTERNS”Optional Variable Default
Section titled “Optional Variable Default”check-optional: tool: if-empty arguments: value: "{{ optional_param }}" goto: true: use-default false: use-provided
use-default: tool: bash arguments: command: echo "default_value" output: var(optional_param) next: continue-workflowPre-flight Validation
Section titled “Pre-flight Validation”validate-inputs: tool: if-empty arguments: value: "{{ required_field }}" goto: true: validation-failed false: check-next-fieldSEE ALSO
Section titled “SEE ALSO”- if-not-empty - Negated version
- if-equal - String equality comparison
- switch - General conditional branching