Auto remove whitespace in the IBAN input field

When adding a payment account Bisq requires IBAN to be whitespace free.

It is annoying for the user to manually clean pasted IBAN of spaces.
In online banking IBAN-s are usually displayed *with* spaces for
better readability.

This commit auto-removes whitespace when user is leaving the input
field, right before validation, effectively allowing to paste
real world IBAN-s.
This commit is contained in:
battleofwizards 2019-08-17 22:36:26 +02:00
parent 62c57cbab7
commit becfdc6819
No known key found for this signature in database
GPG Key ID: 58B1485148D203E1
3 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout;
import bisq.desktop.util.validation.BICValidator;
import bisq.desktop.util.validation.IBANValidator;
import bisq.desktop.util.normalization.IBANNormalizer;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.Country;
@ -39,6 +40,7 @@ import bisq.core.util.validation.InputValidator;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
@ -95,6 +97,7 @@ public class SepaForm extends GeneralSepaForm {
});
ibanInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, IBAN);
ibanInputTextField.setTextFormatter(new TextFormatter<>(new IBANNormalizer()));
ibanInputTextField.setValidator(ibanValidator);
ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
sepaAccount.setIban(newValue);

View File

@ -22,6 +22,7 @@ import bisq.desktop.util.FormBuilder;
import bisq.desktop.util.Layout;
import bisq.desktop.util.validation.BICValidator;
import bisq.desktop.util.validation.IBANValidator;
import bisq.desktop.util.normalization.IBANNormalizer;
import bisq.core.account.witness.AccountAgeWitnessService;
import bisq.core.locale.Country;
@ -39,6 +40,7 @@ import bisq.core.util.validation.InputValidator;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
@ -95,6 +97,7 @@ public class SepaInstantForm extends GeneralSepaForm {
});
ibanInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, IBAN);
ibanInputTextField.setTextFormatter(new TextFormatter<>(new IBANNormalizer()));
ibanInputTextField.setValidator(ibanValidator);
ibanInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
sepaInstantAccount.setIban(newValue);

View File

@ -0,0 +1,15 @@
package bisq.desktop.util.normalization;
import javafx.util.StringConverter;
public class IBANNormalizer extends StringConverter<String> {
@Override
public String toString(String s) {
return s;
}
@Override
public String fromString(String s) {
return s.replaceAll("\\s+", "");
}
}