ValidatedPublisher
public struct ValidatedPublisher<T> : Publisher
ValidationPublisher
A top level publisher that passes validated values or nil
to downstream subscribers.
```
_ = ValidatedPublisher("foo-bar", !.empty && .count(3...))
.replaceNil(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 = Never
-
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
ValidatedPublisher
with the provided output and validator.Declaration
Swift
public init(_ output: T, _ validator: Validator<T>)
Parameters
output
The output to validate before sending downstreaam
validator
The validator to use to validate the output.
-
Attaches a downstreaam
Subscriber
that will receive validated values orFailure
‘sSee also
Publisher
Declaration
Parameters
subscriber
The downstream subscriber to attach.
-
Initializes a new
ValidatedPublisher
with the provided output when the output is alsoValidatable
Declaration
Swift
public init(_ output: T)
Parameters
output
The output to validate before sending downstreaam
See also
Validatable