Spaces:
Sleeping
Sleeping
File size: 1,912 Bytes
83f4356 13c80ac 83f4356 13c80ac 83f4356 55ffa7e 83f4356 55ffa7e 83f4356 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | const { body } = require('express-validator');
const registerValidator = [
body('email').isEmail().withMessage('Valid email is required'),
body('password')
.isStrongPassword({ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1 })
.withMessage('Password must be at least 8 characters and contain at least one lowercase letter, one uppercase letter, one number, and one symbol'),
body('username')
.isLength({ min: 3, max: 30 })
.matches(/^[a-zA-Z0-9_$]+$/)
.withMessage('Username must be 3-30 chars, alphanumeric, underscores, or $'),
body('display_name').optional().isLength({ max: 100 }),
body('role').isIn(['ngo', 'adopter']).withMessage('Role must be "ngo" or "adopter"'),
body('phone').optional().isMobilePhone('any'),
];
const loginValidator = [
body('email').isEmail().withMessage('Valid email is required'),
body('password').notEmpty().withMessage('Password is required'),
];
const updateProfileValidator = [
body('display_name').optional().isLength({ max: 100 }),
body('bio').optional().isLength({ max: 500 }),
body('phone').optional().isMobilePhone('any'),
body('address').optional().isLength({ max: 255 }),
];
const forgotPasswordValidator = [
body('email').isEmail().withMessage('Valid email is required'),
];
const resetPasswordValidator = [
body('new_password')
.isStrongPassword({ minLength: 8, minLowercase: 1, minUppercase: 1, minNumbers: 1, minSymbols: 1 })
.withMessage('Password must be at least 8 characters and contain at least one lowercase letter, one uppercase letter, one number, and one symbol'),
];
const refreshValidator = [
body('refresh_token').isString().isLength({ min: 1, max: 512 }).withMessage('refresh_token is required'),
];
module.exports = {
registerValidator,
loginValidator,
updateProfileValidator,
forgotPasswordValidator,
resetPasswordValidator,
refreshValidator,
};
|