Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added check for empty validation #3573

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
freimair marked this conversation as resolved.
Show resolved Hide resolved
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