The null operator in Graft is used to check if a value is null, empty, or undefined. It returns true if the value is considered "null-like" and false otherwise.
The (( null <reference> )) operator evaluates to:
trueif the reference is:nullornil- An empty string
"" - An empty array
[] - An empty map
{} - A non-existent key (undefined)
falsefor any other value
- basic.yml - Basic null checking examples
- conditional-config.yml - Using null checks in conditional configurations
- default-values.yml - Providing defaults for null values
- validation.yml - Data validation using null checks
- Checking if optional configuration is provided
- Validating required fields
- Providing default values when configuration is missing
- Conditional resource creation based on presence of values
- Data validation in complex configurations
# Check basic null operations
graft merge basic.yml
# Conditional configuration based on null checks
graft merge conditional-config.yml
# Default value handling
graft merge default-values.yml
# Data validation examples
graft merge validation.yml- Empty vs Null: The operator treats empty collections the same as null
- Undefined References: Non-existent keys are considered null
- Type Coercion: No type coercion occurs - only truly empty/null values return true
- Combination with Ternary: Often used with
?:operator for conditional logic