Skip to main content

all

all(booleans: Bag<Bool>)  : Bool

Returns true if all elements of the given collection booleans are true.

  • If the booleans collection is empty, returns true.
  • A null element is considered false.
  • Note that this method accepts both Lists and Bags ─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
}

See also

Types

Functions