Spaces:
Running
Running
File size: 612 Bytes
59c49c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | const { body } = require('express-validator');
exports.changePasswordValidator = [
body('currentPassword')
.notEmpty()
.withMessage('Current password is required'),
body('newPassword')
.notEmpty()
.withMessage('New password is required')
.isLength({ min: 6 })
.withMessage('New password must be at least 6 characters'),
body('confirmNewPassword')
.notEmpty()
.withMessage('Confirm password is required')
.custom((value, { req }) => {
if (value !== req.body.newPassword) {
throw new Error('Passwords do not match');
}
return true;
}),
];
|