TryValidatedPublisher
public struct TryValidatedPublisher<T> : Publisher
TryValidatedPublisher
A top level publisher that passes validated values or BasicValidationError to downstream subscribers.
```
_ = TryValidatedPublisher("foo-bar", !.empty && .count(3...))
.replaceError(with: "Failed"
.sink { print($0) }
// "foo-bar"
```
-
The output type of this publisher.
Declaration
Swift
public typealias Output = T -
The failure type of this publisher.
Declaration
Swift
public typealias Failure = BasicValidationError -
The output that will be validated before passed to downstream subscribers.
Declaration
Swift
public let output: T -
The validator we will use to validate objects before sending them downstream.
Declaration
Swift
public let validator: Validator<T> -
Initializes a new
TryValidatedPublisherwith the provided output and validator.Declaration
Swift
public init(_ output: T, _ validator: Validator<T>)Parameters
outputThe output to validate before sending downstreaam
validatorThe validator to use to validate the output.
-
Attaches a downstreaam
Subscriberthat will receive validated values orFailure‘sSee also
PublisherDeclaration
Parameters
subscriberThe downstream subscriber to attach.
-
Initializes a new
TryValidatedPublisherwith the provided output when the output is alsoValidatableDeclaration
Swift
public init(_ output: T)Parameters
outputThe output to validate before sending downstreaam
See also
Validatable
TryValidatedPublisher Structure Reference