Validate User Input with the database

I want to make the some sort of ATM machine. The user will input the targeted bank account number to transfer, but if the input wrong account number, it will return to the same page where the user input.

I want to check if the user input matches all the entries in the BDM, but i do not know how my code works

How can i do that?

if(BankAccInput == depostDAO.findByBankAcc(BankAcc)){
inputBool = true
}else{
inputBool = false

1 Like

Re-post his code block

if (BankAccInput == depostDAO.findByBankAcc(BankAcc)) {
   inputBool = true
} else {
   inputBool = false

Hi @archaeus8, Does this database schema closely match your database?
image


How about this code?

// BankAccInput is integer, BankAccInput value is sender account number
def senderBankAccount = bankAccountDAO.findByAccount_number(BankAccInput, 0, 1)

// I think you can check if senderBankAccount is not null
if (senderBankAccount == null) {
   // throw an error 
   // and check response of process instantiation API in UI to reload
}

def depost = depostDAO.findByBankAcc(senderBankAccount.account_number)

if (BankAccInput == ... /* your logic*/ ) {
   inputBool = true
} else {
   inputBool = false
1 Like

Yep, that base code works for me, thanks!

1 Like