mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
chore: relocate backend into apps/api ahead of monorepo merge
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/***********************************************************************************************************************************************************************
|
||||
* File Name: auth.validator.js
|
||||
* Type of Program: Validator
|
||||
* Description: express-validator rule chains for authentication endpoints.
|
||||
* - registerValidator → POST /auth/register
|
||||
* - loginValidator → POST /auth/login
|
||||
* - verifyOTPValidator → POST /auth/verify-otp
|
||||
* - resendOTPValidator → POST /auth/resend-otp
|
||||
* - changePassValidator → POST /auth/change-password
|
||||
* - forgotPasswordValidator → POST /auth/forgot-password
|
||||
* - verifyResetOTPValidator → POST /auth/verify-reset-otp
|
||||
* - resetPasswordValidator → POST /auth/reset-password
|
||||
* Author: rgrgogu
|
||||
* Date Created: Oct. 6, 2025
|
||||
* Date Modified: Jul. 4, 2026 — forgot/reset password (Kenneth Obsequio)
|
||||
***********************************************************************************************************************************************************************/
|
||||
const { body } = require('express-validator');
|
||||
|
||||
const registerValidator = [
|
||||
body('email').isEmail().withMessage('Valid email is required.'),
|
||||
body('password')
|
||||
.isLength({ min: 8 })
|
||||
.withMessage('Password must be at least 8 characters.')
|
||||
.matches(/[A-Z]/).withMessage('Password must contain an uppercase letter.')
|
||||
.matches(/[0-9]/).withMessage('Password must contain a number.'),
|
||||
];
|
||||
|
||||
const loginValidator = [
|
||||
body('email').isEmail().withMessage('Valid email is required.'),
|
||||
body('password').notEmpty().withMessage('Password is required.'),
|
||||
body('group_code').optional().isString().trim(),
|
||||
];
|
||||
|
||||
const verifyOTPValidator = [
|
||||
body('email').isEmail(),
|
||||
body('otp').isLength({ min: 6, max: 6 }).isNumeric().withMessage('OTP must be 6 digits.'),
|
||||
];
|
||||
|
||||
const resendOTPValidator = [
|
||||
body('email').isEmail().withMessage('Valid email is required.'),
|
||||
];
|
||||
|
||||
const changePassValidator = [
|
||||
body('current_password').notEmpty().withMessage('Current password is required.'),
|
||||
body('new_password')
|
||||
.isLength({ min: 8 }).withMessage('New password must be at least 8 characters.')
|
||||
.matches(/[A-Z]/).withMessage('Must contain an uppercase letter.')
|
||||
.matches(/[0-9]/).withMessage('Must contain a number.'),
|
||||
];
|
||||
|
||||
const forgotPasswordValidator = [
|
||||
body('email').isEmail().withMessage('Valid email is required.'),
|
||||
];
|
||||
|
||||
const verifyResetOTPValidator = [
|
||||
body('email').isEmail().withMessage('Valid email is required.'),
|
||||
body('otp').isLength({ min: 6, max: 6 }).isNumeric().withMessage('OTP must be 6 digits.'),
|
||||
];
|
||||
|
||||
const resetPasswordValidator = [
|
||||
body('email').isEmail().withMessage('Valid email is required.'),
|
||||
body('otp').isLength({ min: 6, max: 6 }).isNumeric().withMessage('OTP must be 6 digits.'),
|
||||
body('new_password')
|
||||
.isLength({ min: 8 }).withMessage('New password must be at least 8 characters.')
|
||||
.matches(/[A-Z]/).withMessage('Must contain an uppercase letter.')
|
||||
.matches(/[0-9]/).withMessage('Must contain a number.'),
|
||||
];
|
||||
|
||||
module.exports = {
|
||||
registerValidator, loginValidator,
|
||||
verifyOTPValidator, resendOTPValidator, changePassValidator,
|
||||
forgotPasswordValidator, verifyResetOTPValidator, resetPasswordValidator,
|
||||
};
|
||||
Reference in New Issue
Block a user