mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-21 08:06:33 -04:00
Add custom fields and input validation for UK bank accounts
This commit is contained in:
parent
95c072cff3
commit
7e212f1442
@ -19,17 +19,6 @@ package io.bitsquare.locale;
|
||||
|
||||
public class BankUtil {
|
||||
|
||||
public static boolean requiresHolderId(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "BR":
|
||||
case "CL":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO set country specific labels
|
||||
public static String getBankCodeLabel(String countryCode) {
|
||||
@ -50,7 +39,7 @@ public class BankUtil {
|
||||
case "US":
|
||||
return "Routing Number:";
|
||||
case "GB":
|
||||
return "Sort Number:";
|
||||
return "UK Sort code:";
|
||||
case "CA":
|
||||
return "Transit Number:";
|
||||
default:
|
||||
@ -63,6 +52,8 @@ public class BankUtil {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
return "Account number";
|
||||
default:
|
||||
return "Account nr. or IBAN:";
|
||||
}
|
||||
@ -80,4 +71,58 @@ public class BankUtil {
|
||||
return "Personal ID:";
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBankNameRequired(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBankIdRequired(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isBranchIdRequired(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isAccountNrRequired(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isHolderIdRequired(String countryCode) {
|
||||
if (countryCode == null)
|
||||
countryCode = "";
|
||||
switch (countryCode) {
|
||||
case "BR":
|
||||
case "CL":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public abstract class BankAccountContractData extends CountryBasedPaymentAccount
|
||||
protected String holderName;
|
||||
protected String bankName;
|
||||
protected String bankId;
|
||||
protected String branchId = "-";
|
||||
protected String branchId;
|
||||
protected String accountNr;
|
||||
|
||||
@Nullable
|
||||
@ -51,7 +51,7 @@ public abstract class BankAccountContractData extends CountryBasedPaymentAccount
|
||||
|
||||
@Override
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
String holderIdString = BankUtil.requiresHolderId(countryCode) ? (getHolderIdLabel() + ": " + holderTaxId + "\n") : "";
|
||||
String holderIdString = BankUtil.isHolderIdRequired(countryCode) ? (getHolderIdLabel() + ": " + holderTaxId + "\n") : "";
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
"Bank name: " + bankName + "\n" +
|
||||
"Bank Nr.: " + bankId + "\n" +
|
||||
|
@ -62,7 +62,7 @@ public final class SpecificBanksAccountContractData extends BankAccountContractD
|
||||
|
||||
@Override
|
||||
public String getPaymentDetailsForTradePopup() {
|
||||
String holderIdString = BankUtil.requiresHolderId(countryCode) ? (getHolderIdLabel() + ": " + holderTaxId + "\n") : "";
|
||||
String holderIdString = BankUtil.isHolderIdRequired(countryCode) ? (getHolderIdLabel() + ": " + holderTaxId + "\n") : "";
|
||||
return "Holder name: " + holderName + "\n" +
|
||||
holderIdString +
|
||||
"Bank name: " + bankName + "\n" +
|
||||
|
@ -23,6 +23,9 @@ import io.bitsquare.common.util.Tuple4;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.validation.AccountNrValidator;
|
||||
import io.bitsquare.gui.util.validation.BankValidator;
|
||||
import io.bitsquare.gui.util.validation.BranchIdValidator;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.*;
|
||||
import io.bitsquare.payment.BankAccountContractData;
|
||||
@ -52,6 +55,10 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
private Label bankIdLabel;
|
||||
private Label branchIdLabel;
|
||||
private Label accountNrLabel;
|
||||
private Tuple2<Label, InputTextField> bankIdTuple;
|
||||
private Tuple2<Label, InputTextField> accountNrTuple;
|
||||
private Tuple2<Label, InputTextField> branchIdTuple;
|
||||
private Tuple2<Label, InputTextField> bankNameTuple;
|
||||
|
||||
static int addFormForBuyer(GridPane gridPane, int gridRow, PaymentAccountContractData paymentAccountContractData) {
|
||||
BankAccountContractData bankAccountContractData = (BankAccountContractData) paymentAccountContractData;
|
||||
@ -117,31 +124,61 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
getCountryBasedPaymentAccount().setCountry(selectedItem);
|
||||
String countryCode = selectedItem.code;
|
||||
TradeCurrency currency = CurrencyUtil.getCurrencyByCountryCode(countryCode);
|
||||
this.paymentAccount.setSingleTradeCurrency(currency);
|
||||
paymentAccount.setSingleTradeCurrency(currency);
|
||||
currencyTextField.setText(currency.getNameAndCode());
|
||||
|
||||
bankIdLabel.setText(BankUtil.getBankCodeLabel(bankAccountContractData.getCountryCode()));
|
||||
branchIdLabel.setText(BankUtil.getBranchCodeLabel(bankAccountContractData.getCountryCode()));
|
||||
accountNrLabel.setText(BankUtil.getAccountNrLabel(bankAccountContractData.getCountryCode()));
|
||||
bankIdLabel.setText(BankUtil.getBankCodeLabel(countryCode));
|
||||
branchIdLabel.setText(BankUtil.getBranchCodeLabel(countryCode));
|
||||
accountNrLabel.setText(BankUtil.getAccountNrLabel(countryCode));
|
||||
|
||||
if (holderIdInputTextField != null) {
|
||||
boolean requiresHolderId = BankUtil.requiresHolderId(countryCode);
|
||||
holderIdInputTextField.resetValidation();
|
||||
holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode));
|
||||
boolean requiresHolderId = BankUtil.isHolderIdRequired(countryCode);
|
||||
if (requiresHolderId) {
|
||||
holderNameInputTextField.minWidthProperty().unbind();
|
||||
holderNameInputTextField.setMinWidth(300);
|
||||
} else {
|
||||
holderNameInputTextField.minWidthProperty().bind(currencyTextField.widthProperty());
|
||||
holderIdInputTextField.setText("");
|
||||
}
|
||||
holderIdLabel.setText(BankUtil.getHolderIdLabel(countryCode));
|
||||
holderIdLabel.setVisible(requiresHolderId);
|
||||
holderIdLabel.setManaged(requiresHolderId);
|
||||
holderIdInputTextField.resetValidation();
|
||||
holderIdInputTextField.setVisible(requiresHolderId);
|
||||
holderIdInputTextField.setManaged(requiresHolderId);
|
||||
if (!requiresHolderId)
|
||||
holderIdInputTextField.setText("");
|
||||
}
|
||||
|
||||
bankNameTuple.second.resetValidation();
|
||||
bankIdTuple.second.resetValidation();
|
||||
branchIdTuple.second.resetValidation();
|
||||
accountNrTuple.second.resetValidation();
|
||||
|
||||
boolean bankNameRequired = BankUtil.isBankNameRequired(countryCode);
|
||||
bankNameTuple.first.setVisible(bankNameRequired);
|
||||
bankNameTuple.first.setManaged(bankNameRequired);
|
||||
bankNameTuple.second.setVisible(bankNameRequired);
|
||||
bankNameTuple.second.setManaged(bankNameRequired);
|
||||
|
||||
boolean bankIdRequired = BankUtil.isBankIdRequired(countryCode);
|
||||
bankIdTuple.first.setVisible(bankIdRequired);
|
||||
bankIdTuple.first.setManaged(bankIdRequired);
|
||||
bankIdTuple.second.setVisible(bankIdRequired);
|
||||
bankIdTuple.second.setManaged(bankIdRequired);
|
||||
|
||||
boolean branchIdRequired = BankUtil.isBranchIdRequired(countryCode);
|
||||
branchIdTuple.first.setVisible(branchIdRequired);
|
||||
branchIdTuple.first.setManaged(branchIdRequired);
|
||||
branchIdTuple.second.setVisible(branchIdRequired);
|
||||
branchIdTuple.second.setManaged(branchIdRequired);
|
||||
((BankValidator) branchIdTuple.second.getValidator()).setCountryCode(bankAccountContractData.getCountryCode());
|
||||
|
||||
boolean accountNrRequired = BankUtil.isAccountNrRequired(countryCode);
|
||||
accountNrTuple.first.setVisible(accountNrRequired);
|
||||
accountNrTuple.first.setManaged(accountNrRequired);
|
||||
accountNrTuple.second.setVisible(accountNrRequired);
|
||||
accountNrTuple.second.setManaged(accountNrRequired);
|
||||
((BankValidator) accountNrTuple.second.getValidator()).setCountryCode(bankAccountContractData.getCountryCode());
|
||||
|
||||
updateFromInputs();
|
||||
|
||||
onCountryChanged();
|
||||
@ -160,7 +197,8 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
|
||||
addHolderNameAndId();
|
||||
|
||||
bankNameInputTextField = addLabelInputTextField(gridPane, ++gridRow, "Bank name:").second;
|
||||
bankNameTuple = addLabelInputTextField(gridPane, ++gridRow, "Bank name:");
|
||||
bankNameInputTextField = bankNameTuple.second;
|
||||
bankNameInputTextField.setValidator(inputValidator);
|
||||
bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setBankName(newValue);
|
||||
@ -168,9 +206,9 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
|
||||
});
|
||||
|
||||
Tuple2<Label, InputTextField> tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankCodeLabel(""));
|
||||
bankIdLabel = tuple2.first;
|
||||
bankIdInputTextField = tuple2.second;
|
||||
bankIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBankCodeLabel(""));
|
||||
bankIdLabel = bankIdTuple.first;
|
||||
bankIdInputTextField = bankIdTuple.second;
|
||||
bankIdInputTextField.setValidator(inputValidator);
|
||||
bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setBankId(newValue);
|
||||
@ -178,21 +216,20 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
|
||||
});
|
||||
|
||||
tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchCodeLabel(""));
|
||||
branchIdLabel = tuple2.first;
|
||||
|
||||
branchIdInputTextField = tuple2.second;
|
||||
branchIdTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getBranchCodeLabel(""));
|
||||
branchIdLabel = branchIdTuple.first;
|
||||
branchIdInputTextField = branchIdTuple.second;
|
||||
branchIdInputTextField.setValidator(new BranchIdValidator());
|
||||
branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setBranchId(newValue);
|
||||
updateFromInputs();
|
||||
|
||||
});
|
||||
|
||||
tuple2 = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
|
||||
accountNrLabel = tuple2.first;
|
||||
|
||||
accountNrInputTextField = tuple2.second;
|
||||
accountNrInputTextField.setValidator(inputValidator);
|
||||
accountNrTuple = addLabelInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
|
||||
accountNrLabel = accountNrTuple.first;
|
||||
accountNrInputTextField = accountNrTuple.second;
|
||||
accountNrInputTextField.setValidator(new AccountNrValidator());
|
||||
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
|
||||
bankAccountContractData.setAccountNr(newValue);
|
||||
updateFromInputs();
|
||||
@ -244,34 +281,57 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
@Override
|
||||
protected void autoFillNameTextField() {
|
||||
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
|
||||
String bankName = bankNameInputTextField.getText();
|
||||
if (bankName.length() > 6)
|
||||
bankName = StringUtils.abbreviate(bankName, 9);
|
||||
String bankId = null;
|
||||
if (BankUtil.isBankIdRequired(bankAccountContractData.getCountryCode())) {
|
||||
bankId = bankIdInputTextField.getText();
|
||||
if (bankId.length() > 6)
|
||||
bankId = StringUtils.abbreviate(bankId, 9);
|
||||
} else if (BankUtil.isBranchIdRequired(bankAccountContractData.getCountryCode())) {
|
||||
bankId = branchIdInputTextField.getText();
|
||||
if (bankId.length() > 6)
|
||||
bankId = StringUtils.abbreviate(bankId, 9);
|
||||
} else if (BankUtil.isBankNameRequired(bankAccountContractData.getCountryCode())) {
|
||||
bankId = bankNameInputTextField.getText();
|
||||
if (bankId.length() > 6)
|
||||
bankId = StringUtils.abbreviate(bankId, 9);
|
||||
}
|
||||
|
||||
String accountNr = accountNrInputTextField.getText();
|
||||
if (accountNr.length() > 6)
|
||||
accountNr = StringUtils.abbreviate(accountNr, 9);
|
||||
|
||||
String method = BSResources.get(paymentAccount.getPaymentMethod().getId());
|
||||
accountNameTextField.setText(method.concat(", ").concat(bankName).concat(", ").concat(accountNr));
|
||||
if (bankId != null)
|
||||
accountNameTextField.setText(method.concat(", ").concat(bankId).concat(", ").concat(accountNr));
|
||||
else
|
||||
accountNameTextField.setText(method.concat(", ").concat(accountNr));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAllInputsValid() {
|
||||
boolean holderIdValid = true;
|
||||
if (getCountryBasedPaymentAccount().getCountry() != null) {
|
||||
if (BankUtil.requiresHolderId(getCountryBasedPaymentAccount().getCountry().code))
|
||||
holderIdValid = inputValidator.validate(bankAccountContractData.getHolderTaxId()).isValid;
|
||||
}
|
||||
|
||||
allInputsValid.set(isAccountNameValid()
|
||||
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
|
||||
&& holderIdValid
|
||||
boolean result = isAccountNameValid()
|
||||
&& holderNameInputTextField.getValidator().validate(bankAccountContractData.getHolderName()).isValid
|
||||
&& paymentAccount.getSingleTradeCurrency() != null
|
||||
&& getCountryBasedPaymentAccount().getCountry() != null);
|
||||
&& getCountryBasedPaymentAccount().getCountry() != null;
|
||||
|
||||
if (BankUtil.isBankNameRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= bankNameInputTextField.getValidator().validate(bankAccountContractData.getBankName()).isValid;
|
||||
|
||||
if (BankUtil.isBankIdRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= bankIdInputTextField.getValidator().validate(bankAccountContractData.getBankId()).isValid;
|
||||
|
||||
if (BankUtil.isBranchIdRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= branchIdInputTextField.getValidator().validate(bankAccountContractData.getBranchId()).isValid;
|
||||
|
||||
if (BankUtil.isAccountNrRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= accountNrInputTextField.getValidator().validate(bankAccountContractData.getAccountNr()).isValid;
|
||||
|
||||
if (getCountryBasedPaymentAccount().getCountry() != null &&
|
||||
BankUtil.isHolderIdRequired(getCountryBasedPaymentAccount().getCountry().code))
|
||||
result &= holderIdInputTextField.getValidator().validate(bankAccountContractData.getHolderTaxId()).isValid;
|
||||
|
||||
allInputsValid.set(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -293,7 +353,7 @@ abstract class BankForm extends PaymentMethodForm {
|
||||
}
|
||||
|
||||
protected void addHolderNameAndIdForDisplayAccount() {
|
||||
if (BankUtil.requiresHolderId(bankAccountContractData.getCountryCode())) {
|
||||
if (BankUtil.isHolderIdRequired(bankAccountContractData.getCountryCode())) {
|
||||
Tuple4<Label, TextField, Label, TextField> tuple = addLabelTextFieldLabelTextField(gridPane, ++gridRow,
|
||||
"Account holder name:", BankUtil.getHolderIdLabel(bankAccountContractData.getCountryCode()));
|
||||
TextField holderNameTextField = tuple.second;
|
||||
|
@ -21,6 +21,7 @@ import io.bitsquare.common.util.Tuple2;
|
||||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.validation.InputValidator;
|
||||
import io.bitsquare.locale.BankUtil;
|
||||
import io.bitsquare.payment.CountryBasedPaymentAccount;
|
||||
import io.bitsquare.payment.PaymentAccount;
|
||||
import io.bitsquare.payment.PaymentAccountContractData;
|
||||
@ -58,14 +59,24 @@ public class SameBankForm extends BankForm {
|
||||
|
||||
@Override
|
||||
public void updateAllInputsValid() {
|
||||
allInputsValid.set(isAccountNameValid()
|
||||
boolean result = isAccountNameValid()
|
||||
&& inputValidator.validate(bankAccountContractData.getHolderName()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBankName()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBankId()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getBranchId()).isValid
|
||||
&& inputValidator.validate(bankAccountContractData.getAccountNr()).isValid
|
||||
&& paymentAccount.getSingleTradeCurrency() != null
|
||||
&& ((CountryBasedPaymentAccount) paymentAccount).getCountry() != null);
|
||||
&& ((CountryBasedPaymentAccount) paymentAccount).getCountry() != null;
|
||||
|
||||
if (BankUtil.isBankNameRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= inputValidator.validate(bankAccountContractData.getBankName()).isValid;
|
||||
|
||||
if (BankUtil.isBankIdRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= inputValidator.validate(bankAccountContractData.getBankId()).isValid;
|
||||
|
||||
if (BankUtil.isBranchIdRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= inputValidator.validate(bankAccountContractData.getBranchId()).isValid;
|
||||
|
||||
if (BankUtil.isAccountNrRequired(bankAccountContractData.getCountryCode()))
|
||||
result &= inputValidator.validate(bankAccountContractData.getAccountNr()).isValid;
|
||||
|
||||
allInputsValid.set(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.util.validation;
|
||||
|
||||
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
||||
public final class AccountNrValidator extends BankValidator {
|
||||
|
||||
@Override
|
||||
public ValidationResult validate(String input) {
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
try {
|
||||
Integer.parseInt(input);
|
||||
if (input.length() != 8) {
|
||||
return new ValidationResult(false, BSResources.get("validation.ukAccountNr"));
|
||||
} else {
|
||||
return super.validate(input);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
return new ValidationResult(false, BSResources.get("validation.ukAccountNr"));
|
||||
}
|
||||
default:
|
||||
return super.validate(input);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.util.validation;
|
||||
|
||||
|
||||
public abstract class BankValidator extends InputValidator {
|
||||
protected String countryCode = "";
|
||||
|
||||
public BankValidator() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setCountryCode(String countryCode) {
|
||||
this.countryCode = countryCode;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.gui.util.validation;
|
||||
|
||||
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
||||
public final class BranchIdValidator extends BankValidator {
|
||||
@Override
|
||||
public ValidationResult validate(String input) {
|
||||
switch (countryCode) {
|
||||
case "GB":
|
||||
try {
|
||||
Integer.parseInt(input);
|
||||
if (input.length() != 6) {
|
||||
return new ValidationResult(false, BSResources.get("Sort code must consist of 6 numbers"));
|
||||
} else {
|
||||
return super.validate(input);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
return new ValidationResult(false, BSResources.get("validation.ukSortCode"));
|
||||
}
|
||||
default:
|
||||
return super.validate(input);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -27,6 +27,8 @@ validation.btc.toSmall=Input results in a bitcoin value with a fraction of the s
|
||||
validation.btc.toLarge=Input larger as maximum trading amount of {0} is not allowed.
|
||||
validation.passwordTooShort=The password you entered is too short. It needs to have min. 8 characters.
|
||||
validation.passwordTooLong=The password you entered is too long. It cannot be longer as 50 characters.
|
||||
validation.ukSortCode=Sort code must consist of 6 numbers
|
||||
validation.ukAccountNr=Account number must consist of 8 numbers
|
||||
|
||||
# Create offer
|
||||
createOffer.amount.prompt=Enter amount in BTC
|
||||
|
Loading…
x
Reference in New Issue
Block a user