if-has-value
The if-has-value Instruction conditionally executes a nested lists of Instructions depending on whether a Destination has a value set. This is useful for setting default values.
action |
"if-has-value" |
destination |
The Destination to check. |
name |
The Name within the Destination. |
then |
An array of Instructions to be executed when the value exists in the Destination (optional). |
else |
An array of Instructions to be executed when the value does not exist in the Destination (optional). |
See also if-exists.
Example: setting defaults
To ensure a object always has a title by applying a default if no other value has been set, add this to the end of your control file’s Instructions.
{
"action": "if-has-value",
"destination": "book",
"name": "dc:attribute:title",
"else": [
{
"action": "set-value",
"destination": "book",
"name": "dc:attribute:title",
"value": "Unnamed project"
}
]
}