all
all(booleans: Bag<Bool>) : Bool
Returns true if all elements of the given collection booleans are true.
- If the
booleanscollection is empty, returnstrue. - A
nullelement is consideredfalse. - Note that this method accepts both
ListsandBags─since Lists subtype Bags
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
}