diff --git a/GME Remit/Extensions/UITextField+Ext.swift b/GME Remit/Extensions/UITextField+Ext.swift index 1ff30914..7795838a 100644 --- a/GME Remit/Extensions/UITextField+Ext.swift +++ b/GME Remit/Extensions/UITextField+Ext.swift @@ -11,7 +11,6 @@ import RxSwift import RxCocoa public enum GMEKeyboardType: String { - case uppercaseAlphabet = "UA" case alphabet = "A" case alphabetNumberic = "AN" case alphabetNumbericSpecial = "ANS" @@ -19,15 +18,16 @@ public enum GMEKeyboardType: String { } extension UITextField { - func filterBy(type: GMEKeyboardType, isSendAction: Bool = true) { + func filterBy(type: GMEKeyboardType, isSendAction: Bool = true, isUppercase: Bool = false) { let extractText: String? + let value = isUppercase ? text?.uppercased() : text + switch type { - case .uppercaseAlphabet: extractText = text?.uppercased().extract(regex: "[A-Z\\s]") - case .alphabet: extractText = text?.extract(regex: "[A-Za-z\\s]") - case .alphabetNumberic: extractText = text?.extract(regex: "[A-Z0-9a-z\\s]") - case .alphabetNumbericSpecial: extractText = text?.filter { $0.isASCII } + case .alphabet: extractText = value?.extract(regex: "[A-Za-z\\s]") + case .alphabetNumberic: extractText = value?.extract(regex: "[A-Z0-9a-z\\s]") + case .alphabetNumbericSpecial: extractText = value?.filter { $0.isASCII } case .numberic: extractText = text?.extract(regex: "[0-9]") } @@ -128,10 +128,10 @@ extension UITextField { } extension Reactive where Base: UITextField { - public func filterBy(_ type: GMEKeyboardType) -> Disposable { + public func filterBy(_ type: GMEKeyboardType, isUppercase: Bool = false) -> Disposable { let disposable = self.base.rx.controlEvent(.editingChanged) .subscribe(onNext: { - self.base.filterBy(type: type) + self.base.filterBy(type: type, isUppercase: isUppercase) }) return disposable } diff --git a/GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipientViewController.swift b/GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipientViewController.swift index ff9df550..0255a17a 100644 --- a/GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipientViewController.swift +++ b/GME Remit/Modules/RecipientModules/SetupRecipient/User Interface/View/SetupRecipientViewController.swift @@ -467,8 +467,10 @@ extension SetupRecipientViewController { textField.rx.controlEvent(.editingChanged).asDriver() .drive(onNext: { _ in switch keyType { - case .numberic: textField.filterBy(type: .alphabetNumberic, isSendAction: false) - default: textField.filterBy(type: keyType, isSendAction: false) + case .numberic: + textField.filterBy(type: .alphabetNumberic, isSendAction: false, isUppercase: true) + default: + textField.filterBy(type: keyType, isSendAction: false, isUppercase: true) } }).disposed(by: disposeBag) } diff --git a/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegisterStep1/User Interface/View/NewRegisterStep1ViewController.swift b/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegisterStep1/User Interface/View/NewRegisterStep1ViewController.swift index 4589e80f..13ba6fa0 100644 --- a/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegisterStep1/User Interface/View/NewRegisterStep1ViewController.swift +++ b/GME Remit/Modules/RegisterModules/UserAuthentication/NewRegisterStep1/User Interface/View/NewRegisterStep1ViewController.swift @@ -401,13 +401,13 @@ extension NewRegisterStep1ViewController { self?.anotherIDImageTrigger.onNext(nil) }).disposed(by: disposeBag) - userNameTextField.rx.filterBy(.uppercaseAlphabet).disposed(by: disposeBag) + userNameTextField.rx.filterBy(.alphabet, isUppercase: true).disposed(by: disposeBag) emailTextField.rx.filterBy(.alphabetNumbericSpecial).disposed(by: disposeBag) - addressTextField.rx.filterBy(.alphabet).disposed(by: disposeBag) + addressTextField.rx.filterBy(.alphabet, isUppercase: true).disposed(by: disposeBag) bankAccountTextField.rx.filterBy(.numberic).disposed(by: disposeBag) - passportNumberTextField.rx.filterBy(.alphabetNumberic).disposed(by: disposeBag) + passportNumberTextField.rx.filterBy(.alphabetNumberic, isUppercase: true).disposed(by: disposeBag) idNumberTextField.rx.filterBy("[0-9-]").disposed(by: disposeBag) - referralTextField.rx.filterBy(.alphabetNumberic).disposed(by: disposeBag) + referralTextField.rx.filterBy(.alphabetNumberic, isUppercase: true).disposed(by: disposeBag) }