Stop validation fall through for Reader API adds/edits
This commit is contained in:
parent
1035fd7b76
commit
2edd558139
|
@ -109,8 +109,9 @@ class ReaderAPIAccountViewController: UITableViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func action(_ sender: Any) {
|
@IBAction func action(_ sender: Any) {
|
||||||
|
guard validateDataEntry() else {
|
||||||
validateDataEntry()
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let username = usernameTextField.text!
|
let username = usernameTextField.text!
|
||||||
let password = passwordTextField.text!
|
let password = passwordTextField.text!
|
||||||
|
@ -201,23 +202,24 @@ class ReaderAPIAccountViewController: UITableViewController {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
private func validateDataEntry() {
|
private func validateDataEntry() -> Bool {
|
||||||
switch accountType {
|
switch accountType {
|
||||||
case .freshRSS:
|
case .freshRSS:
|
||||||
if !usernameTextField.hasText || !passwordTextField.hasText || !apiURLTextField.hasText {
|
if !usernameTextField.hasText || !passwordTextField.hasText || !apiURLTextField.hasText {
|
||||||
showError(NSLocalizedString("Username, password, and API URL are required.", comment: "Credentials Error"))
|
showError(NSLocalizedString("Username, password, and API URL are required.", comment: "Credentials Error"))
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
guard let _ = URL(string: apiURLTextField.text!) else {
|
guard let _ = URL(string: apiURLTextField.text!) else {
|
||||||
showError(NSLocalizedString("Invalid API URL.", comment: "Invalid API URL"))
|
showError(NSLocalizedString("Invalid API URL.", comment: "Invalid API URL"))
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
if !usernameTextField.hasText || !passwordTextField.hasText {
|
if !usernameTextField.hasText || !passwordTextField.hasText {
|
||||||
showError(NSLocalizedString("Username and password are required.", comment: "Credentials Error"))
|
showError(NSLocalizedString("Username and password are required.", comment: "Credentials Error"))
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private func apiURL() -> URL? {
|
private func apiURL() -> URL? {
|
||||||
|
|
Loading…
Reference in New Issue