samoulla-backend / validators /authValidations.js
Samoulla Sync Bot
Auto-deploy Samoulla Backend: 19c8fe03f7b7b0f52ba4ad506ac1341bcb562d57
1459d1b
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;
}),
];