extracted payment password validator from transfer route to its own validator
This commit is contained in:
@@ -1,24 +1,10 @@
|
||||
const transferController = require('../controllers/transfer.controller');
|
||||
const { logger } = require('../util/logger');
|
||||
const express = require('express');
|
||||
const tpinValidator = require('../validators/tpin.validator');
|
||||
const tpasswordValidator = require('../validators/tpassword.validator');
|
||||
const transferValidator = require('../validators/transfer.validator');
|
||||
const passwordValidator = require('../validators/payment.secret.validator.js');
|
||||
|
||||
const router = express.Router();
|
||||
// Added for tpassword
|
||||
const passwordValidator=async(req,res,next)=>{
|
||||
const{tpin,tpassword} =req.body;
|
||||
if(tpin){
|
||||
return tpinValidator(req,res,next);
|
||||
}
|
||||
else if(tpassword){
|
||||
return tpasswordValidator(req,res,next);
|
||||
}
|
||||
else{
|
||||
return res.status(400).json({error:"tpin or tpassword is required"})
|
||||
}
|
||||
}
|
||||
router.use(passwordValidator, transferValidator);
|
||||
|
||||
const transferRoute = async (req, res) => {
|
||||
|
15
src/validators/payment.secret.validator.js
Normal file
15
src/validators/payment.secret.validator.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const tpasswordValidator = require('./tpassword.validator.js');
|
||||
const tpinValidator = require('./tpin.validator.js');
|
||||
|
||||
const paymentSecretValidator = async (req, res, next) => {
|
||||
const { tpin, tpassword } = req.body;
|
||||
if (tpin) {
|
||||
return tpinValidator(req, res, next);
|
||||
} else if (tpassword) {
|
||||
return tpasswordValidator(req, res, next);
|
||||
} else {
|
||||
return res.status(400).json({ error: 'tpin or tpassword is required' });
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = paymentSecretValidator;
|
Reference in New Issue
Block a user