Skip to main content

all

all(booleans: List<Bool>) : Bool

Returns true if all elements of the List are true. If the List is empty, returns true. A null element is considered false.

This function will raise an error if the List is absent.

Examples:

emptyList =
foreach x in fromTo(1, 0)
select true;

[{ allWithOnlyTrues: all([true, true]), /* ==> true */
allWithOnlyFalses: all([false, false]), /* ==> false */
allWithSomeTrues: all([true, false, true]), /* ==> false */
allWithEmptyList: all(emptyList), /* ==> true */
}
]

The following example query finds for each device if all password-policy config satisfies long password length:

pattern = ```
password-policy minimum-length {minLength:number}
```;

LONG_PASSWORD_LENGTH = 15;

foreach device in network.devices
let config = device.files.config
select {
Device: device.name,
OnlyLongPassword: if hasBlockMatch(config, pattern)
then all(foreach match in blockMatches(config, pattern)
select match.data.minLength >= LONG_PASSWORD_LENGTH)
else false
}

See also

Types

Functions