mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 19:26:27 +00:00
Refactor backend services and preserve transaction contracts
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
const { body } = require('express-validator');
|
||||
|
||||
// Aturan input untuk setiap operasi. Urutan validasi mengikuti kontrak API.
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case 'loginPartnerUser': {
|
||||
return [
|
||||
body('email')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Email is required')
|
||||
.isEmail()
|
||||
.withMessage('Email format wrong'),
|
||||
body('password').not().isEmpty().withMessage('Password is required'),
|
||||
];
|
||||
}
|
||||
case 'loginTerminal': {
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('password').not().isEmpty().withMessage('Password is required'),
|
||||
];
|
||||
}
|
||||
case 'register': {
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('password')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Password is required')
|
||||
.isLength({ min: 5 })
|
||||
.withMessage('Password must be least 5 characters'),
|
||||
];
|
||||
}
|
||||
case 'refreshTokenPartnerUser': {
|
||||
return [
|
||||
body('email')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Email is required')
|
||||
.isEmail()
|
||||
.withMessage('Email format wrong'),
|
||||
];
|
||||
}
|
||||
case 'refreshTokenTerminal': {
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module.exports = validate;
|
||||
Reference in New Issue
Block a user