samoulla-backend / validators /authValidations.js
Samoulla Sync Bot
Auto-deploy Samoulla Backend: b68e45770de26ed39feb4b1c0925e5345eb3a61d
634b9bb
raw
history blame contribute delete
612 Bytes
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;
}),
];