Controller
flashKeyExists()
Signature
Section titled “Signature”flashKeyExists() — returns boolean
Available in: controller
Category: Flash Functions
Description
Section titled “Description”The flashKeyExists() function checks whether a specific key is present in the Flash scope. It returns true if the key exists and false if it does not. This is useful for conditionally displaying or processing Flash messages or data before attempting to read them.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | yes | — | The key to check. |
Examples
Section titled “Examples”1. Check if the "error" key exists
errorExists = flashKeyExists("error");
2. Conditional display based on key existence
if (flashKeyExists("notice")) {
writeOutput(flash("notice"));
}
3. Example usage in a form flow
if (flashKeyExists("validationErrors")) {
errors = flash("validationErrors");
// Process or display errors
}