Files
yume_js/src/validators/transfer.validator.js
tomosa.sarkar d4d741b8cc feat : Implement last las login feature
feat : add transaction password column and write logic for transaction password.
2025-07-22 12:49:44 +05:30

21 lines
724 B
JavaScript

const transferValidator = async (req, res, next) => {
const { fromAccount, toAccount, toAccountType, amount } = req.body;
const accountTypes = ['SB', 'LN','Savings','Current'];
if (!fromAccount || fromAccount.length != 11) {
return res.status(400).json({ error: 'INVALID_ACCOUNT_NUMBER_FORMAT' });
}
if (!toAccount || toAccount.length != 11) {
return res.status(400).json({ error: 'INVALID_ACCOUNT_NUMBER_FORMAT' });
}
if (!accountTypes || !accountTypes.includes(toAccountType)) {
return res.status(400).json({ error: 'INVALID_ACCOUNT_TYPE' });
}
if (!amount || amount <= 0) {
return res.status(400).json({ error: 'INVALID_AMOUNT' });
}
next();
};
module.exports = transferValidator;