Report templatesFunctions
addDefault
Provide a default value for null or undefined inputs
Usage
The addDefault function returns a custom default value when the input is null or undefined.
Syntax
{input | addDefault:customDefault}Parameters
input(any): The value to checkcustomDefault(any): The value to return if input is null or undefined
Returns
- The original
inputif it's not null or undefined - The
customDefaultvalue if input is null or undefined
Examples
Basic default
{null | addDefault:"N/A"}
// Returns: "N/A"Value exists
{"Active" | addDefault:"Unknown"}
// Returns: "Active"With undefined
{undefined | addDefault:"No data"}
// Returns: "No data"Empty string handling
{"" | addDefault:"Empty"}
// Returns: "" (empty string is not null/undefined)With vulnerability data
{vulnerability.cvss_score | addDefault:"Not scored"}
// Returns CVSS score or "Not scored" if nullNumeric defaults
{user.loginCount | addDefault:0}
// Returns login count or 0 if nullUse Cases
- Handling missing data in reports
- Providing fallback values for optional fields
- Ensuring consistent display of empty values
- Default values for configuration settings
- Placeholder text for undefined properties
Note
This function only checks for null and undefined. Empty strings, zero, and false are considered valid values and will not trigger the default.