---
title: "allSatisfy(_:)"
framework: combine
role: symbol
role_heading: Instance Method
path: "combine/publisher/allsatisfy(_:)"
---

# allSatisfy(_:)

Publishes a single Boolean value that indicates whether all received elements pass a given predicate.

## Declaration

```swift
func allSatisfy(_ predicate: @escaping (Self.Output) -> Bool) -> Publishers.AllSatisfy<Self>
```

## Parameters

- `predicate`: A closure that evaluates each received element. Return true to continue, or false to cancel the upstream and complete.

## Return Value

Return Value A publisher that publishes a Boolean value that indicates whether all received elements pass a given predicate.

## Discussion

Discussion Use the allSatisfy(_:) operator to determine if all elements in a stream satisfy a criteria you provide. When this publisher receives an element, it runs the predicate against the element. If the predicate returns false, the publisher produces a false value and finishes. If the upstream publisher finishes normally, this publisher produces a true value and finishes. In the example below, the allSatisfy(_:) operator tests if each an integer array publisher’s elements fall into the targetRange: let targetRange = (-1...100) let numbers = [-1, 0, 10, 5] numbers.publisher     .allSatisfy { targetRange.contains($0) }     .sink { print("\($0)") }

// Prints: "true" With operators similar to reduce(_:_:), this publisher produces at most one value. note: Upon receiving any request greater than zero, this publisher requests unlimited elements from the upstream publisher.

## See Also

### Applying matching criteria to elements

- [contains(_:)](combine/publisher/contains(_:).md)
- [contains(where:)](combine/publisher/contains(where:).md)
- [tryContains(where:)](combine/publisher/trycontains(where:).md)
- [tryAllSatisfy(_:)](combine/publisher/tryallsatisfy(_:).md)
