🚦 Validation library depends on SwiftUI & Combine. Reactive and fully customizable.

Overview

CombineValidate

License Swift versions Platforms codecov Test And Coverage

What is CombineValidate?

Useful satellite for validation user inputs proposes for any SwiftUI architectures. (MVVM as basic reference)

Batteries:

  • SwiftUI native
  • Combine under the hood
  • Fully customizable
  • Validate simple fields for non empty values
  • Validate fields by predefined or your own regular expressions
  • Try input by multiple regex expressions and emerge up the result what is the regex got fired
  • Pass your own error messages
  • Localize error messages with custom localization table names
  • Use the wide validation extension library
  • Extend the set of validation possibilities as you want

Examples

Basic usage

Firstly you should define the validation publisher within your @Published property

class FormViewModel: ObservableObject {
    
    @Published var email = ""
    public lazy var emailValidator: ValidationPublisher = {
        $email.validateWithRegex(
            regex: RegularPattern.email,
            error: "Not email",
            tableName: nil
        )
    }()
}

Excellent! And then, call the validate view modifier from your SwiftUI Input

TextField("Should email", text: $viewModel.email)
        .validate(for: viewModel.emailValidator)

Enjoy!

Same steps you can apply to SecureField and Toggle.

CombineValidateExtended library

Useful set of validation publishers and regular expressions library. Validation for

  • any kind of credit card numbers
  • urls
  • hash tags
  • numbers
  • passwords
  • much more

Requirements

The CombineValidate dependes on the Combine reactive framework. Minimal requirements:

  • iOS 13
  • MacOS Catalina

Installation

Package installation occurs via SPM. Add package in your Xcode as dependency

Documentation

Look at here and explore documentation.

You might also like...
iOS validation framework with form validation support

ATGValidator ATGValidator is a validation framework written to address most common issues faced while verifying user input data. You can use it to val

iOS validation framework with form validation support

ATGValidator ATGValidator is a validation framework written to address most common issues faced while verifying user input data. You can use it to val

Reactive WebSockets - A lightweight abstraction layer over Starscream to make it reactive.

RxWebSocket Reactive extensions for websockets. A lightweight abstraction layer over Starscream to make it reactive. Installation RxWebSocket is avail

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.
SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations.

SwiftCop is a validation library fully written in Swift and inspired by the clarity of Ruby On Rails Active Record validations. Objective Build a stan

iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit
iOS native app demo with Xcode and Swift using MVVM architecture and Apple's Combine framework for functional reactive programming, all with UIKit

iOS (Swift 5): MVVM test with Combine and UIKit MVVM and functional reactive programming (FRP) are very used in iOS development inside companies. Here

Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)
Spin aims to provide a versatile Feedback Loop implementation working with the three main reactive frameworks available in the Swift community (RxSwift, ReactiveSwift and Combine)

With the introduction of Combine and SwiftUI, we will face some transition periods in our code base. Our applications will use both Combine and a thir

Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.
Mini-application iOS native avec Xcode et Swift exploitant l'architecture MVVM et le framework Combine d'Apple pour la mise en place de la programmation réactive fonctionnelle, le tout avec UIKit.

iOS (Swift 5): Test MVVM avec Combine et UIKit L'architecture MVVM et la programmation réactive fonctionnelle sont très utlisées dans le développement

Unidirectional reactive architecture using new Apple Combine framework
Unidirectional reactive architecture using new Apple Combine framework

Unidirectional Reactive Architecture. This is a Combine implemetation of ReactiveFeedback and RxFeedback

SwiftUI library to create fully customizable input stepper.
SwiftUI library to create fully customizable input stepper.

SwiftUI-InputStepper Swift package for creating numerical input stepper. An example of input stepper created with this library It supports long press

content for Using Combine - notes on learning Combine with UIKit and SwiftUI
content for Using Combine - notes on learning Combine with UIKit and SwiftUI

SwiftUI-Notes A collection of notes, project pieces, playgrounds and ideas on learning and using SwiftUI and Combine. Changes, corrections, and feedba

A fully customizable iOS calendar library, compatible with Objective-C and Swift
A fully customizable iOS calendar library, compatible with Objective-C and Swift

Table of contents Screenshots Installation Pre-knowledge Support Contact Screenshots iPhone iPad Safe Orientation Today Extension iOS8/9 iOS10 Interac

Former is a fully customizable Swift library for easy creating UITableView based form.
Former is a fully customizable Swift library for easy creating UITableView based form.

Former is a fully customizable Swift library for easy creating UITableView based form. Submitting Issues Click HERE to get started with filing a bug r

A fully customizable library to easily display Animated Toast Messages in iOS using Swift!
A fully customizable library to easily display Animated Toast Messages in iOS using Swift!

CustomToastView-swift A fully customizable library to easily display Animated Toast Messages in iOS using Swift! Preview - All the custom toasts you c

A fully customizable iOS Horizontal PickerView library, written in pure swift
A fully customizable iOS Horizontal PickerView library, written in pure swift

ADDatePicker is Horizontal Date Picker Library written in Swift Requirements Communication Installation Usage Demo Customization Credits License Requi

A New, Modern Reactive State Management Library for Swift and SwiftUI (The iOS implementation of Recoil)
A New, Modern Reactive State Management Library for Swift and SwiftUI (The iOS implementation of Recoil)

RecoilSwift RecoilSwift is a lightweight & reactive swift state management library. RecoilSwift is a SwiftUI implementation of recoil.js which powered

⚛️ A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency.
⚛️ A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency.

SwiftUI Atom Properties A Reactive Data-Binding and Dependency Injection Library for SwiftUI x Concurrency 📔 API Reference Introduction Examples Gett

A SwiftUI Partial Sheet fully customizable with dynamic height
A SwiftUI Partial Sheet fully customizable with dynamic height

A SwiftUI Partial Sheet fully customizable with dynamic height

Fully customizable line chart for SwiftUI 🤩
Fully customizable line chart for SwiftUI 🤩

🧀 CheesyChart Create amazing Crypto and Stock charts 📈 📉 Looking for an easy to use and fully customizable charting solution written in SwiftUI? Th

Brands-Combine - A demo for Using Combine with UIKit

Brands-Combine Brands is demo for Using Combine with UIKit What did i use ? Simp

Comments
  • Custom Regular Expression

    Custom Regular Expression

    I'm having a hard time understanding how to validate using a custom regex string. I see the enum of various types of pre-set expressions, but how does one validate for something outside of those definitions? If I try to pass a string as the regex, I get an error that the string does not conform to the RegularPattern protocol.

    question 
    opened by donniefitz2 2
  • validateOneOfRegex usage?

    validateOneOfRegex usage?

    Trying to use validateOneOfRegex to combine multiple regexes for credit card validation but seem to be missing something.

    public lazy var validatiorCreditCard : ValidationPublisher = {
            $cardNumber.validateOneOfRegex(
                regexs: [CreditCardPattern.Mastercard,CreditCardPattern.Amex,CreditCardPattern.Discover,CreditCardPattern.Visa],
                error: "Invalid Card Number"
            )
        }()
    

    Keeps throwing error "Type 'Void' cannot conform to RegexProtocol" and "Cannot convert value of type 'CreditCardPattern' to expected element type 'Array<Void>.ArrayLiteralElement' (aka '()')"

    opened by Captnwalker1 1
  • When Form is Valid

    When Form is Valid

    I haven't been able to figure out how to know when all form fields are valid. For instance, I have several fields and I want to disable the save button until the fields are all valid. I have a boolean property disabling the save button called isFormDisabled that I want to enable once all of the fields are valid.

    Here's what I have in my view model: `@Published var firstName = "" @Published var lastName = "" @Published var userName = "" @Published var vehicleYear = "" @Published var vehicleMake = "" @Published var vehicleModel = "" @Published var vehicleNickName = ""

    public lazy var emtpyFirstNameValidator: ValidationPublisher = {
        $firstName.validateNonEmpty(error: "Please enter your first name", tableName: nil)
    }()
    
    public lazy var emptyLastNameValidator: ValidationPublisher = {
        $lastName.validateNonEmpty(error: "Please enter your last name", tableName: nil)
    }()
    
    public lazy var emptyUserNameValidator: ValidationPublisher = {
        $userName.validateNonEmpty(error: "Please create a username", tableName: nil)
    }()
    
    public lazy var vehicleYearValidator: ValidationPublisher = {
        $vehicleYear.validateWithRegex(regex: CustomRegexPatterns.vehicleYear, error: "Please enter a valid vehicle year", tableName: nil)
    }()
    
    public lazy var emptyVehicleMakeValidator: ValidationPublisher = {
        $vehicleMake.validateNonEmpty(error: "Please enter your vehicle make", tableName: nil)
    }()
    
    public lazy var emptyVehicleModelValidator: ValidationPublisher = {
        $vehicleModel.validateNonEmpty(error: "Please enter your vehicle model", tableName: nil)
    }()`
    

    I reviewed the examples, but I'm not quite sure how to know when the form is valid.

    Thanks.

    question 
    opened by donniefitz2 1
  • Suggestion: Make debounce length a configurable variable

    Suggestion: Make debounce length a configurable variable

    0.25 is much to quick for most people typing, so that the validation message shows up while they are typing. At a minimum would double to 0.5, but would be handy to have as a configurable variable.

    enhancement 
    opened by Captnwalker1 1
Releases(1.1.0)
  • 1.1.0(Dec 7, 2021)

    Flex and easy

    For now you can use validation more flexible

    Validate complex structures with map keypath field deriving

     public lazy var emailValidator: ValidationPublisher = {
          $person.map(\.email)
              .validateWithRegex(
                  regex: RegularPattern.email,
                  error: "Not email",
                  tableName: nil
              )
      }()
    

    call .validate from any view as you want

    makeRowWithIconAndPrefix(icon: "icon_facebook", prefix: "facebook.com/") {
        TextField("Facebook", text: $viewModel.editedProfile.facebook)
    }
    .validate(for: viewModel.facebookValidator, configuration: .hintOnly)
    

    Feel free to make your contribution!

    Good luck!

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Nov 26, 2021)

  • 1.0.1(Nov 13, 2021)

  • 1.0.0(Nov 9, 2021)

  • 1.0.0-beta3(Nov 7, 2021)

  • 1.0.0-beta2(Nov 7, 2021)

Owner
Alexo
Alexo
Swift Validator is a rule-based validation library for Swift.

Swift Validator is a rule-based validation library for Swift. Core Concepts UITextField + [Rule] + (and optional error UILabel) go into

null 1.4k Dec 29, 2022
String (and more) validation for iOS

Swift Validators ?? String validation for iOS. Contents Installation Walkthrough Usage Available validators License ReactiveSwift + SwiftValidators Wa

George Kaimakas 241 Nov 13, 2022
RxValidator Easy to Use, Read, Extensible, Flexible Validation Checker.

RxValidator Easy to Use, Read, Extensible, Flexible Validation Checker. It can use without Rx. Requirements RxValidator is written in Swift 4.

GeumSang Yoo 153 Nov 17, 2022
Drop in user input validation for your iOS apps.

Validator Validator is a user input validation library written in Swift. It's comprehensive, designed for extension, and leaves the UI up to you. Here

Adam Waite 1.4k Dec 29, 2022
Validation plugin for Moya.Result

MoyaResultValidate Why? Sometimes we need to verify that the data returned by the server is reasonable, when Moya returns Result.success. JSON returne

Insect_QY 1 Dec 15, 2021
Input Validation Done Right. A Swift DSL for Validating User Input using Allow/Deny Rules

Valid Input Validation Done Right. Have you ever struggled with a website with strange password requirements. Especially those crazy weird ones where

Mathias Quintero 37 Nov 3, 2022
Input Mask is an Android & iOS native library allowing to format user input on the fly.

Migration Guide: v.6 This update brings breaking changes. Namely, the autocomplete flag is now a part of the CaretGravity enum, thus the Mask::apply c

red_mad_robot 548 Dec 20, 2022
Declarative form validator for SwiftUI.

SwiftUIFormValidator The world's easiest, most clean SwiftUI form validation. SwiftUIFormValidator A declarative SwiftUI form validation. Clean, simpl

Shaban Kamel 42 Dec 13, 2022
A framework to validate inputs of text fields and text views in a convenient way.

FormValidatorSwift The FormValidatorSwift framework allows you to validate inputs of text fields and text views in a convenient way. It has been devel

ustwo™ 500 Nov 29, 2022
Generate a list of licenses for the Swift Package libraries that your app depends on.

LicenseList Generate a list of licenses for the Swift Package libraries that your app depends on. Example Requirements Written in Swift 5 Compatible w

Cybozu 40 Dec 19, 2022