mirror of
https://github.com/haveno-dex/haveno.git
synced 2024-11-16 15:58:08 +00:00
validate form fields on create payment account from form
Some checks failed
CI / build (macos-13) (push) Has been cancelled
CI / build (ubuntu-22.04) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
Codacy Coverage Reporter / Publish coverage (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Some checks failed
CI / build (macos-13) (push) Has been cancelled
CI / build (ubuntu-22.04) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
Codacy Coverage Reporter / Publish coverage (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
This commit is contained in:
parent
485746381c
commit
aee0c1c0b2
1 changed files with 11 additions and 0 deletions
|
@ -64,9 +64,14 @@ class CorePaymentAccountsService {
|
|||
}
|
||||
|
||||
PaymentAccount createPaymentAccount(PaymentAccountForm form) {
|
||||
validateFormFields(form);
|
||||
PaymentAccount paymentAccount = form.toPaymentAccount();
|
||||
setSelectedTradeCurrency(paymentAccount); // TODO: selected trade currency is function of offer, not payment account payload
|
||||
verifyPaymentAccountHasRequiredFields(paymentAccount);
|
||||
if (paymentAccount instanceof CryptoCurrencyAccount) {
|
||||
CryptoCurrencyAccount cryptoAccount = (CryptoCurrencyAccount) paymentAccount;
|
||||
verifyCryptoCurrencyAddress(cryptoAccount.getSingleTradeCurrency().getCode(), cryptoAccount.getAddress());
|
||||
}
|
||||
user.addPaymentAccountIfNotExists(paymentAccount);
|
||||
accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
|
||||
log.info("Saved payment account with id {} and payment method {}.",
|
||||
|
@ -166,6 +171,12 @@ class CorePaymentAccountsService {
|
|||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void validateFormFields(PaymentAccountForm form) {
|
||||
for (PaymentAccountFormField field : form.getFields()) {
|
||||
validateFormField(form, field.getId(), field.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
void validateFormField(PaymentAccountForm form, PaymentAccountFormField.FieldId fieldId, String value) {
|
||||
|
||||
// get payment method id
|
||||
|
|
Loading…
Reference in a new issue