Swiftpack.co - xattacker/RequiredPropertyChecker as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by xattacker.
xattacker/RequiredPropertyChecker 1.0.0
a Combine related component, help checking property has been filled
⭐️ 0
🕓 32 weeks ago
.package(url: "https://github.com/xattacker/RequiredPropertyChecker.git", from: "1.0.0")


a Swift Combine Related component, help checking property has been filled

another congeneric project: https://github.com/xattacker/RxRequiredPropertyChecker
(which implemented by RxSwift)

Demo Video




RequiredPropertyChecker can be added to your project using CocoaPods 0.36 or later by adding the following line to your Podfile:

pod 'RequiredPropertyChecker'

Swift Package Manager

To add RequiredPropertyChecker to a Swift Package Manager based project, add:

.package(url: "https://github.com/xattacker/RequiredPropertyChecker.git", .upToNextMajor(from: "1.0.0")),

to your Package.swift files dependencies array.

How to use:

import RequiredPropertyChecker
import Combine

// make the component implement protocol RequiredProperty
extension UITextField: RequiredProperty
    public var isFilled: Bool
        return (self.text?.count ?? 0) > 0

    public var isFilledPublisher: AnyPublisher<Bool, Never>
        let p1 = NotificationCenter.default
                   .publisher(for: UITextField.textDidChangeNotification, object: self)
                   .map { (($0.object as? UITextField)?.text?.count ?? 0) > 0 }

        let p2 = self.publisher(for: \.text).map { ($0?.count ?? 0) > 0 }

        return p1.merge(with: p2).eraseToAnyPublisher()

// then add the RequiredProperty instance into RequiredPropertyChecker
let textField: UITextField
var set = Set<AnyCancellable>()
let checker = RequiredPropertyChecker()

// bind checker with other
            .sink {
                [weak self]
                filled in
                self?.button.isEnable = filled
            }.store(in: &set)


Stars: 0
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

32 weeks ago

first release

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics