containsAll

Full name: taxi.stdlib.containsAll

Signature

declare extension function <T> containsAll(collection: T[], searchTarget:T[]): Boolean

Description

Returns true if the collection contains every element in the search targets array.

Returns true when searchTargets is empty (an empty set is a subset of every set).

// Check whether a product has all required tags
find {
   hasCertified: Boolean = ProductTag[].containsAll(['certified', 'in-stock'])
}

Known limitation: When the collection uses a semantic type (e.g. ProductTag inherits String), passing string literals as searchTargets always returns false due to a type comparison bug. See problems/containsAll.md. Use a String[] collection as a workaround.

Examples

Returns true when the collection contains all specified search values, false if any are missing.

Try it out

Schema
Query Plan
Play with this snippet by editing it here, or edit it on Taxi Playground
Result
Query failed
Next
Welcome to Taxi