summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJon Petersson <jon.petersson@kvadrat.se>2023-08-30 14:07:38 +0200
committerEmīls <emils@mullvad.net>2023-09-11 17:04:01 +0200
commit1c9a3b047d65fa502d63037ad3f176139cbbeb3c (patch)
treee260fc5bdd83c01509fc9bbb2304089ef55d6fea
parentba70363b55af905534ddaaf9cb9dced91dfaccba (diff)
downloadmullvadvpn-1c9a3b047d65fa502d63037ad3f176139cbbeb3c.tar.xz
mullvadvpn-1c9a3b047d65fa502d63037ad3f176139cbbeb3c.zip
On delete account screen, add account number validation during input
-rw-r--r--ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift17
1 files changed, 13 insertions, 4 deletions
diff --git a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift
index bfdfea5892..e3fce9f69b 100644
--- a/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift
+++ b/ios/MullvadVPN/View controllers/AccountDeletion/AccountDeletionContentView.swift
@@ -253,9 +253,18 @@ class AccountDeletionContentView: UIView {
}
}
- private var isAccountNumberLengthSatisfied: Bool {
- let length = accountTextField.text?.count ?? 0
- return length == 4
+ private var isInputValid: Bool {
+ guard let input = accountTextField.text,
+ let accountNumber = viewModel?.accountNumber,
+ !accountNumber.isEmpty
+ else {
+ return false
+ }
+
+ let inputLengthIsValid = input.count == 4
+ let inputMatchesAccountNumber = accountNumber.suffix(4) == input
+
+ return inputLengthIsValid && inputMatchesAccountNumber
}
weak var delegate: AccountDeletionContentViewDelegate?
@@ -334,7 +343,7 @@ class AccountDeletionContentView: UIView {
} else {
activityIndicator.stopAnimating()
}
- deleteButton.isEnabled = isDeleteButtonEnabled && isAccountNumberLengthSatisfied
+ deleteButton.isEnabled = isDeleteButtonEnabled && isInputValid
statusLabel.text = text
statusLabel.textColor = textColor
}