Skip to content

Commit

Permalink
Added check for empty validation
Browse files Browse the repository at this point in the history
This commit is for github issue #3458 and #3459
check added for moneybeam and national bank transfer
  • Loading branch information
beingindot committed Nov 13, 2019
1 parent 61e51a0 commit 755ca19
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public ValidationResult validate(String input) {
}

protected ValidationResult validateIfNotEmpty(String input) {
if (input == null || input.length() == 0)
//trim added to avoid empty input
if (input == null || input.trim().length() == 0)
return new ValidationResult(false, Res.get("validation.empty"));
else
return new ValidationResult(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,28 +240,28 @@ public void addFormForAddAccount() {
bankNameInputTextField = addInputTextField(gridPane, ++gridRow, Res.get("payment.bank.name"));

bankNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setBankName(newValue);
bankAccountPayload.setBankName(newValue.trim());
updateFromInputs();

});

bankIdInputTextField = addInputTextField(gridPane, ++gridRow, BankUtil.getBankIdLabel(""));
bankIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setBankId(newValue);
bankAccountPayload.setBankId(newValue.trim());
updateFromInputs();

});

branchIdInputTextField = addInputTextField(gridPane, ++gridRow, BankUtil.getBranchIdLabel(""));
branchIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setBranchId(newValue);
bankAccountPayload.setBranchId(newValue.trim());
updateFromInputs();

});

accountNrInputTextField = addInputTextField(gridPane, ++gridRow, BankUtil.getAccountNrLabel(""));
accountNrInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setAccountNr(newValue);
bankAccountPayload.setAccountNr(newValue.trim());
updateFromInputs();

});
Expand Down Expand Up @@ -381,7 +381,7 @@ private void addHolderNameAndId() {
holderNameInputTextField = tuple.first;
holderNameInputTextField.setMinWidth(250);
holderNameInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
bankAccountPayload.setHolderName(newValue);
bankAccountPayload.setHolderName(newValue.trim());
updateFromInputs();
});
holderNameInputTextField.minWidthProperty().bind(currencyComboBox.widthProperty());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void validateInput(String countryCode) {
bankNameInputTextField.setValidator(null);
bankIdInputTextField.setValidator(null);
branchIdInputTextField.setValidator(null);
accountNrInputTextField.setValidator(null);
accountNrInputTextField.setValidator(inputValidator);
nationalAccountIdInputTextField.setValidator(null);
}
}
Expand All @@ -142,20 +142,20 @@ void autoFillAccountTextFields(CountryBasedPaymentAccountPayload paymentAccountP
if (countryCode == null)
countryCode = "";
if (BankUtil.isBankIdRequired(countryCode)) {
bankId = bankIdInputTextField.getText();
bankId = bankIdInputTextField.getText().trim();
if (bankId.length() > 9)
bankId = StringUtils.abbreviate(bankId, 9);
} else if (BankUtil.isBranchIdRequired(countryCode)) {
bankId = branchIdInputTextField.getText();
bankId = branchIdInputTextField.getText().trim();
if (bankId.length() > 9)
bankId = StringUtils.abbreviate(bankId, 9);
} else if (BankUtil.isBankNameRequired(countryCode)) {
bankId = bankNameInputTextField.getText();
bankId = bankNameInputTextField.getText().trim();
if (bankId.length() > 9)
bankId = StringUtils.abbreviate(bankId, 9);
}

String accountNr = accountNrInputTextField.getText();
String accountNr = accountNrInputTextField.getText().trim();
if (accountNr.length() > 9)
accountNr = StringUtils.abbreviate(accountNr, 9);

Expand Down Expand Up @@ -200,7 +200,10 @@ boolean getValidationResult(boolean result, String countryCode, String bankName,

if (BankUtil.isNationalAccountIdRequired(countryCode))
result = result && nationalAccountIdInputTextField.getValidator().validate(nationalAccountId).isValid;
} else { // only account number not empty validation
result = result && accountNrInputTextField.getValidator().validate(accountNr).isValid;
}

return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void addFormForAddAccount() {
accountIdInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.moneyBeam.accountId"));
accountIdInputTextField.setValidator(validator);
accountIdInputTextField.textProperty().addListener((ov, oldValue, newValue) -> {
account.setAccountId(newValue);
account.setAccountId(newValue.trim());
updateFromInputs();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ void applyTradeCurrency(TradeCurrency tradeCurrency, FiatCurrency defaultCurrenc

void setAccountNameWithString(String name) {
if (useCustomAccountNameToggleButton != null && !useCustomAccountNameToggleButton.isSelected()) {
name = name.trim();
name = StringUtils.abbreviate(name, 9);
String method = Res.get(paymentAccount.getPaymentMethod().getId());
accountNameTextField.setText(method.concat(": ").concat(name));
Expand Down

0 comments on commit 755ca19

Please sign in to comment.