commit 99ad38fb6c76bedb7b50b6da4062af06787ec146
parent bdd4d2f109a237170fafac364410abb6c51454cb
Author: Marc Stibane <marc@taler.net>
Date: Sat, 21 Nov 2026 21:46:26 +0100
AI: #12064 x-Taler validation
Diffstat:
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/TalerWallet1/Views/Settings/Bank/BankEditView.swift b/TalerWallet1/Views/Settings/Bank/BankEditView.swift
@@ -59,6 +59,13 @@ struct BankEditView: View {
// }
// }
+ /// An x-taler-bank target is BANK-HOST/ACCOUNT (RFC 8905) with two components
+ private var xTalerValid: Bool {
+ let parts = xTaler.split(separator: "/", omittingEmptySubsequences: false)
+ return parts.count >= 2
+ && parts.allSatisfy { !$0.isEmpty && !$0.contains(where: { $0.isWhitespace }) }
+ }
+
@ViewBuilder func barButton() -> some View {
let isNew = accountID == nil
let titleStr = isNew ? String(localized: "Add", comment: "button title: Add bank account")
@@ -66,7 +73,7 @@ struct BankEditView: View {
let a11yStr = isNew ? String(localized: "Add bank account", comment: "a11y")
: String(localized: "Update bank account", comment: "a11y")
let notValid: Bool = paytoType == .iban ? (iban.isEmpty || !ibanValid)
- : xTaler.isEmpty
+ : !xTalerValid
DoneButton(titleStr: titleStr, accessibilityLabelStr: titleStr) {
Task {
if await updateAccount() {
@@ -105,7 +112,7 @@ struct BankEditView: View {
let isIBAN = paytoType == .iban
if !accountHolder.isEmpty && !accountLabel.isEmpty {
if isIBAN ? !iban.isEmpty
- : !xTaler.isEmpty {
+ : xTalerValid {
// Build the payto URI with URLComponents so each component is escaped as a
// component. The previous code percent-encoded the ALREADY-ASSEMBLED string
// with .urlQueryAllowed, which leaves "?", "&" and "=" untouched — an
@@ -259,19 +266,27 @@ struct BankEditView: View {
}
}
} else if paytoType == .xTalerBank {
- TextField(paytoStr, text: $xTaler)
+ TextField("BANK-HOST/ACCOUNT", text: $xTaler)
.accessibilityLabel(paytoColon)
.focused($focus, equals: .xTaler)
.talerFont(.title3)
.foregroundColor(WalletColors().fieldForeground) // text color
.background(WalletColors().fieldBackground)
.textFieldStyle(.roundedBorder)
- .padding(.bottom)
+ .autocapitalization(.none)
+ .disableAutocorrection(true)
+ .padding(.bottom, xTaler.isEmpty || xTalerValid ? nil : 0)
.onChange(of: xTaler) { newValue in
if userTyped {
unchanged = false
}
}
+ if !xTaler.isEmpty && !xTalerValid {
+ Text("Enter the account as BANK-HOST/ACCOUNT",
+ comment: "hint below the x-taler-bank field")
+ .talerFont(.body)
+ .padding(.bottom)
+ }
} else {
Text("unknown payment method")
.talerFont(.title3)