mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:56:27 +00:00
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
const { body } = require('express-validator');
|
|
|
|
// Aturan input untuk setiap operasi. Urutan validasi mengikuti kontrak API.
|
|
const validate = (method) => {
|
|
switch (method) {
|
|
case 'loadingBalanceRequest':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
body('uid').not().isEmpty().withMessage('UID is required'),
|
|
body('flag').not().isEmpty().withMessage('Flag is required'),
|
|
body('card_number')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Card Number is required'),
|
|
];
|
|
case 'loadingBalance':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
body('uid').not().isEmpty().withMessage('UID is required'),
|
|
body('flag').not().isEmpty().withMessage('Flag is required'),
|
|
body('card_number')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Card Number is required'),
|
|
body('amount')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Amount is required')
|
|
.isNumeric()
|
|
.withMessage('Amount is invalid format'),
|
|
body('reservation_number')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Reservation Number is required')
|
|
.isArray()
|
|
.withMessage('Reservation Number is invalid request format'),
|
|
];
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
|
|
|
|
module.exports = validate;
|