SRL Core Functions

Text, conversion, presence, numeric, certificate, and configuration metadata functions.

lower()

Definition and usage

Converts text to lowercase.

Syntax

lower(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value converted to text.

Return value

Return typestring
OutputLowercase text.

Examples

Example 1
lower("HTTPS")
Expected return value: https
Example 2
lower(this.status)
Expected return value: enable

upper()

Definition and usage

Converts text to uppercase.

Syntax

upper(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value converted to text.

Return value

Return typestring
OutputUppercase text.

Examples

Example 1
upper("https")
Expected return value: HTTPS
Example 2
upper(this.name)
Expected return value: ADMIN-PORTAL

trim()

Definition and usage

Removes whitespace from the start and end of text.

Syntax

trim(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value converted to text.

Return value

Return typestring
OutputTrimmed text.

Examples

Example 1
trim("  enabled  ")
Expected return value: enabled
Example 2
trim(this.comment)
Expected return value: Approved by change control

replace()

Definition and usage

Replaces literal text or a delimited regular-expression pattern.

Syntax

replace(pattern, replacement, subject)

Parameter values

ParameterAllowed typeRequiredDescription
pattern string Yes Literal text or a delimited regex.
replacement string Yes Replacement text.
subject mixed Yes Source value converted to text.

Return value

Return typestring
OutputUpdated text; the original text is returned if a regex is invalid.

Examples

Example 1
replace(" ", "-", "admin portal")
Expected return value: admin-portal
Example 2
replace("/[0-9]+/", "N", "port123")
Expected return value: portN
Behavior: Regex replacement uses PHP-compatible delimiters, but only inside this function; matches_regex is used for boolean regex tests.

contains()

Definition and usage

Tests whether text or a collection contains a search value.

Syntax

contains(value, search)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Text or collection to search.
search mixed Yes Text or collection value to find.

Return value

Return typeboolean
Outputtrue when a case-insensitive match is found using the same semantics as the contains operator.

Examples

Example 1
contains("FTP_GET, FTP_PUT", "FTP_GET")
Expected return value: true
Example 2
contains("HTTPS", "SSH")
Expected return value: false
Behavior: For rules using interpreter version 2, nested collection values are flattened before matching, consistent with the contains operator.

split()

Definition and usage

Splits text into a list.

Syntax

split(value, delimiter = ",")

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value converted to text.
delimiter string No Separator; defaults to a comma.

Return value

Return typelist
OutputA sequential list of text segments.

Examples

Example 1
split("a,b,c", ",")
Expected return value: ["a", "b", "c"]
Example 2
split("wan1 port2", " ")
Expected return value: ["wan1", "port2"]

join()

Definition and usage

Combines scalar list values into text.

Syntax

join(list, delimiter = ",")

Parameter values

ParameterAllowed typeRequiredDescription
list list Yes List of scalar values.
delimiter string No Separator; defaults to a comma.

Return value

Return typestring
OutputJoined text.

Examples

Example 1
join(split("a,b,c", ","), " | ")
Expected return value: a | b | c
Example 2
join(this.member, ", ")
Expected return value: port1, port2

string()

Definition and usage

Converts a value to SRL text.

Syntax

string(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value to convert.

Return value

Return typestring
OutputText representation; configuration nodes use FortiGate-style block rendering.

Examples

Example 1
string(15)
Expected return value: 15
Example 2
string(true)
Expected return value: true

number()

Definition and usage

Converts a value to a number.

Syntax

number(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value to convert.

Return value

Return typenumber
OutputA numeric value; unresolved or non-numeric input becomes zero.

Examples

Example 1
number("15")
Expected return value: 15
Example 2
number("timeout=30")
Expected return value: 30

bool()

Definition and usage

Converts common enabled/disabled text and scalar values to a boolean.

Syntax

bool(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value to convert.

Return value

Return typeboolean
Outputtrue or false.

Examples

Example 1
bool("enabled")
Expected return value: true
Example 2
bool("off")
Expected return value: false

count()

Definition and usage

Counts visible entries in an array or configuration collection.

Syntax

count(value)

Parameter values

ParameterAllowed typeRequiredDescription
value collection Yes Collection to count.

Return value

Return typeinteger
OutputVisible entry count; non-arrays return zero.

Examples

Example 1
count(split("a,b,c", ","))
Expected return value: 3
Example 2
count(config.firewall.policy)
Expected return value: Number of visible policies

len()

Definition and usage

Returns string length or visible array count.

Syntax

len(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Text or collection to measure.

Return value

Return typeinteger
OutputCharacter count for text or entry count for arrays.

Examples

Example 1
len("HTTPS")
Expected return value: 5
Example 2
len(this.member)
Expected return value: Number of members

exists()

Definition and usage

Tests whether a value is resolved and non-empty.

Syntax

exists(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value or path to test.

Return value

Return typeboolean
Outputtrue when the value exists and is non-empty.

Examples

Example 1
exists(this.comment)
Expected return value: true when comment is populated
Example 2
exists(this.missing-field)
Expected return value: false

not_exists()

Definition and usage

Inverse of exists().

Syntax

not_exists(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value or path to test.

Return value

Return typeboolean
Outputtrue when the value is missing or empty.

Examples

Example 1
not_exists(this.comment)
Expected return value: true when comment is absent
Example 2
not_exists("text")
Expected return value: false

empty()

Definition and usage

Tests whether a value is missing or empty.

Syntax

empty(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value or path to test.

Return value

Return typeboolean
Outputtrue for missing or empty input.

Examples

Example 1
empty(this.member)
Expected return value: true when no members exist
Example 2
empty("HTTPS")
Expected return value: false

not_empty()

Definition and usage

Tests whether a value is resolved and non-empty.

Syntax

not_empty(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value or path to test.

Return value

Return typeboolean
Outputtrue for populated input.

Examples

Example 1
not_empty(this.member)
Expected return value: true when members exist
Example 2
not_empty("")
Expected return value: false

is_true()

Definition and usage

Applies SRL boolean conversion and tests for true.

Syntax

is_true(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value to test.

Return value

Return typeboolean
OutputConverted truth value.

Examples

Example 1
is_true("on")
Expected return value: true
Example 2
is_true("disabled")
Expected return value: false

is_false()

Definition and usage

Applies SRL boolean conversion and tests for false.

Syntax

is_false(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Value to test.

Return value

Return typeboolean
OutputInverse converted truth value.

Examples

Example 1
is_false("off")
Expected return value: true
Example 2
is_false(1)
Expected return value: false

number_gt()

Definition and usage

Tests whether a is numerically greater than b.

Syntax

number_gt(a, b)

Parameter values

ParameterAllowed typeRequiredDescription
a mixed Yes Left numeric value.
b mixed Yes Right numeric value.

Return value

Return typeboolean
OutputNumeric comparison result.

Examples

Example 1
number_gt("30", 15)
Expected return value: true
Example 2
number_gt(10, 10)
Expected return value: false

number_gte()

Definition and usage

Tests whether a is numerically greater than or equal to b.

Syntax

number_gte(a, b)

Parameter values

ParameterAllowed typeRequiredDescription
a mixed Yes Left numeric value.
b mixed Yes Right numeric value.

Return value

Return typeboolean
OutputNumeric comparison result.

Examples

Example 1
number_gte(10, 10)
Expected return value: true
Example 2
number_gte(9, 10)
Expected return value: false

number_lt()

Definition and usage

Tests whether a is numerically less than b.

Syntax

number_lt(a, b)

Parameter values

ParameterAllowed typeRequiredDescription
a mixed Yes Left numeric value.
b mixed Yes Right numeric value.

Return value

Return typeboolean
OutputNumeric comparison result.

Examples

Example 1
number_lt(9, 10)
Expected return value: true
Example 2
number_lt(10, 10)
Expected return value: false

number_lte()

Definition and usage

Tests whether a is numerically less than or equal to b.

Syntax

number_lte(a, b)

Parameter values

ParameterAllowed typeRequiredDescription
a mixed Yes Left numeric value.
b mixed Yes Right numeric value.

Return value

Return typeboolean
OutputNumeric comparison result.

Examples

Example 1
number_lte(10, 10)
Expected return value: true
Example 2
number_lte(11, 10)
Expected return value: false

name()

Definition and usage

Returns the configuration entry name stored in SRL annotation metadata.

Syntax

name(value)

Parameter values

ParameterAllowed typeRequiredDescription
value mixed Yes Usually this or a configuration node.

Return value

Return typestring
OutputEntry name, or the scalar text when no metadata exists.

Examples

Example 1
name(this)
Expected return value: wan1
Example 2
name($group.primary)
Expected return value: Address-Office

path()

Definition and usage

Returns the full annotated configuration path.

Syntax

path(value)

Parameter values

ParameterAllowed typeRequiredDescription
value configuration node Yes Annotated configuration value.

Return value

Return typestring
OutputDot-separated path, or empty text for a non-node.

Examples

Example 1
path(this)
Expected return value: config.firewall.policy.10
Example 2
path("text")
Expected return value: empty string

parent()

Definition and usage

Resolves the annotated parent configuration node.

Syntax

parent(value)

Parameter values

ParameterAllowed typeRequiredDescription
value configuration node Yes Annotated configuration value.

Return value

Return typeconfiguration node or empty
OutputParent node when available.

Examples

Example 1
name(parent(this))
Expected return value: policy
Example 2
path(parent(this))
Expected return value: config.firewall.policy