function validationRules() { return [ check('first_name').not().isEmpty().withMessage('First name is required'), check('last_name').not().isEmpty().withMessage('Last name is required'), check('gender').not().isEmpty().withMessage('Gender is required').isIn(['M', 'F']), check('date_of_birth').toDate().optional({ checkFalsy: true }), check('mobile').optional({ checkFalsy: true }).isInt(), check('address').optional({ checkFalsy: true, nullable: true }).isLength({ min: 10 }).withMessage('Please enter minimum 10 characters'), check('email').optional({ checkFalsy: true, nullable: true }).isEmail().withMessage('Please enter valid email') ]; }
router.post(`/${REMIT}/`, [ body('from_account_no').exists().withMessage('from_account_no is required'), body('from_account_no').isLength({min:16, max:16}).matches(/\d/).withMessage('from_account_no is not 16 digits'), body('to_account_no').exists().withMessage('to_account_no is required'), body('to_account_no').isLength({min:16, max:16}).matches(/\d/).withMessage('to_account_no is not 16 digits'), body('amount').exists().withMessage('amount is required'), body('amount').isInt({min:0}).withMessage('amount is not int or amount is less than zero'), ], (req, res, next) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(400).json({error: errors.mapped() }); } const data = { chaincodeId: CHAINCODE_NAME, fcn: 'remit', args: [req.body.from_account_no, req.body.to_account_no, req.body.amount.toString()], }; invoke(data, req, res, next); });
query('page') .optional() .isInt({ min: 1 }) .toInt(), (req, res) => {
router.post(`/${DEPOSIT}/`, [ body('to_account_no').exists().withMessage('to_account_no is required'), body('to_account_no').isLength({min:16, max:16}).matches(/\d/).withMessage('account_no is not 16 digits'), body('amount').exists().withMessage('amount is required'), body('amount').isInt({min:0}).withMessage('amount is not int or amount is less than zero'), ], (req, res, next) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(400).json({error: errors.mapped() }); } const data = { chaincodeId: CHAINCODE_NAME, fcn: 'deposit', args: [req.body.to_account_no, req.body.amount.toString()], }; invoke(data, req, res, next); });
query('page') .optional() .isInt() .toInt(), (req, res) => {
router.post(`/${WITHDRAW}/`, [ body('from_account_no').exists().withMessage('from_account_no is required'), body('from_account_no').isLength({min:16, max:16}).matches(/\d/).withMessage('account_no is not 16 digits'), body('amount').exists().withMessage('amount is required'), body('amount').isInt({min:0}).withMessage('amount is not int or amount is less than zero'), ], (req, res, next) => { const errors = validationResult(req); if (!errors.isEmpty()) { return res.status(400).json({error: errors.mapped() }); } const data = { chaincodeId: CHAINCODE_NAME, fcn: 'withdraw', args: [req.body.from_account_no, req.body.amount.toString()], }; invoke(data, req, res, next); });
query('page') .optional() .isInt({ min: 1 }) .toInt(), (req, res) => {
query('page') .optional() .isInt() .toInt(), (req, res) => {