Skip to main content

any

any(booleans: List<Bool>) : Bool

Returns true if any element of the List is true. If the List is empty, returns false. 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;

[{ 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