Skip to content

Rahul-Mayani/RRFormValidation

Repository files navigation

RRFormValidation

iOS Swift 5+ Validation Architecture

Form validation by RxSwift with MVVM architecture

Example

alt text

Requirements

pod 'RxCocoa'

pod 'RxSwift'

pod 'Action'

pod 'IQKeyboardManagerSwift'

Installation

Manually

  1. Download the project.
  2. Add necessary files in your project.
  3. Congratulations!

Usage example

To run the example project, clone the repo, and run pod install from the Example directory first.

formViewModel.nameSubject <~> nameTextField.rx.text => rxbag // Two-way binding is donated by <~>
formViewModel.submitButtonEnabled ~> submitButton.rx.valid => rxbag // One-way binding is donated by ~>
submitButton.rx.bind(to: formViewModel.submitAction, input: ()) // action binding

formViewModel.submitAction.executionObservables.switchLatest()
.subscribe(onNext: { formData in
    print(formData.parameters as Any)
    UIAlertController.showAlert(title: "Form Validator", message: "Success")
}) => rxbag

formViewModel.formLoadingSubject.skip(1)
.subscribe(onNext: { [weak self] (isLoading) in
    guard let self = self else {return}
    self.view.endEditing(true)
    if isLoading {
        self.submitButton?.startAnimation()
    } else {
        self.submitButton?.stopAnimation()
    }
}) => rxbag

Contribute

We would love you for the contribution to RRFormValidation, check the LICENSE file for more info.

License

RRFormValidation is available under the MIT license. See the LICENSE file for more info.

Releases

No releases published

Packages

No packages published