Skip to main content

any

any(booleans: Bag<Bool>)  : Bool

Returns true if any element of the given collection booleans is true.

  • If the booleans collection is empty, returns false.
  • 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;

[{ anyWithOnlyTrues: any([true, true]), /* ==> true */
anyWithOnlyFalses: any([false, false]), /* ==> false */
anyWithSomeTrues: any([false, false, true]), /* ==> true */
anyWithEmptyList: any(emptyList), /* ==> false */
}
]

The following example query finds for each device if any 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,
HasLongPassword: any(foreach match in blockMatches(config, pattern)
select match.data.minLength >= LONG_PASSWORD_LENGTH)
}

See also

Types

Functions