Spaces:
Running
Running
| 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; | |
| }), | |
| ]; | |