mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-05 10:56:27 +00:00
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
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;
|