From 2edd55813946452882d4012f90933f9b4d845148 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Tue, 27 Oct 2020 14:45:21 -0500 Subject: [PATCH] Stop validation fall through for Reader API adds/edits --- iOS/Account/ReaderAPIAccountViewController.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/iOS/Account/ReaderAPIAccountViewController.swift b/iOS/Account/ReaderAPIAccountViewController.swift index e755f73cb..676dcb1ad 100644 --- a/iOS/Account/ReaderAPIAccountViewController.swift +++ b/iOS/Account/ReaderAPIAccountViewController.swift @@ -109,8 +109,9 @@ class ReaderAPIAccountViewController: UITableViewController { } @IBAction func action(_ sender: Any) { - - validateDataEntry() + guard validateDataEntry() else { + return + } let username = usernameTextField.text! let password = passwordTextField.text! @@ -201,23 +202,24 @@ class ReaderAPIAccountViewController: UITableViewController { return nil } - private func validateDataEntry() { + private func validateDataEntry() -> Bool { switch accountType { case .freshRSS: if !usernameTextField.hasText || !passwordTextField.hasText || !apiURLTextField.hasText { showError(NSLocalizedString("Username, password, and API URL are required.", comment: "Credentials Error")) - return + return false } guard let _ = URL(string: apiURLTextField.text!) else { showError(NSLocalizedString("Invalid API URL.", comment: "Invalid API URL")) - return + return false } default: if !usernameTextField.hasText || !passwordTextField.hasText { showError(NSLocalizedString("Username and password are required.", comment: "Credentials Error")) - return + return false } } + return true } private func apiURL() -> URL? {