mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 11:06:28 +00:00
87 lines
2.7 KiB
JavaScript
87 lines
2.7 KiB
JavaScript
const { body } = require('express-validator');
|
|
|
|
// Aturan input untuk setiap operasi. Urutan validasi mengikuti kontrak API.
|
|
const validate = (method) => {
|
|
switch (method) {
|
|
case 'checkReservation':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
body('card_number')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Card Number is required'),
|
|
];
|
|
case 'reservationValidate':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID 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'),
|
|
];
|
|
case 'reservation':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
body('card_number')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Card Number is required'),
|
|
body('ref_no').not().isEmpty().withMessage('Ref No is required'),
|
|
body('amount')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Amount is required')
|
|
.isNumeric()
|
|
.withMessage('Amount is invalid format'),
|
|
];
|
|
case 'reservationV2':
|
|
return [
|
|
body('reservation_data')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Reservation data is required'),
|
|
body('ref_no').not().isEmpty().withMessage('Ref No is required'),
|
|
];
|
|
case 'cancelReservation':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
body('reservation_number')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Reservation Number is required'),
|
|
];
|
|
case 'cancelReservationValidateV2':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
];
|
|
case 'cancelReservationV2':
|
|
return [
|
|
body('cancel_reservation_data')
|
|
.not()
|
|
.isEmpty()
|
|
.withMessage('Cancel Reservation data is required'),
|
|
];
|
|
case 'getFeeSharing':
|
|
return [
|
|
body('mid').not().isEmpty().withMessage('MID is required'),
|
|
body('tid').not().isEmpty().withMessage('TID is required'),
|
|
];
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
|
|
|
|
module.exports = validate;
|