<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Publisher/tryAllSatisfy(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine9PublisherPAAE13tryAllSatisfyyAA10PublishersO03TrydE0Vy_xGSb6OutputQzKcF"
  },
  "title" : "tryAllSatisfy(_:)"
}
-->

# tryAllSatisfy(_:)

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

```
func tryAllSatisfy(_ predicate: @escaping (Self.Output) throws -> Bool) -> Publishers.TryAllSatisfy<Self>
```

## Parameters

`predicate`

A closure that evaluates each received element. Return `true` to continue, or `false` to cancel the upstream and complete. The closure may throw an error, in which case the publisher cancels the upstream publisher and fails with the thrown error.

## Return Value

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

## Discussion

Use the [`tryAllSatisfy(_:)`](/documentation/Combine/Publisher/tryAllSatisfy(_:)) operator to determine if all elements in a stream satisfy a criteria in an error-throwing predicate 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. If the predicate throws an error, the publisher fails and passes the error to its downstream subscriber.

In the example below, an error-throwing predicate tests if each of an integer array publisher’s elements fall into the `targetRange`; the predicate throws an error if an element is zero and terminates the stream.

```
let targetRange = (-1...100)
let numbers = [-1, 10, 5, 0]

numbers.publisher
    .tryAllSatisfy { anInt in
        guard anInt != 0 else { throw RangeError() }
        return targetRange.contains(anInt)
    }
    .sink(
        receiveCompletion: { print ("completion: \($0)") },
        receiveValue: { print ("value: \($0)") }
    )

// Prints: "completion: failure(RangeError())"
```

With operators similar to [`reduce(_:_:)`](/documentation/Combine/Publisher/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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)