From 1b73905bd6bfb0d7c1320e8b7994713b4dc27213 Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 9 Nov 2024 12:09:29 +0100 Subject: [PATCH] Enhanced joi validation closes #7 --- src/validations/auth.validation.ts | 6 +++--- src/validations/password.validation.ts | 6 ++++-- src/validations/verifyEmail.validation.ts | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/validations/auth.validation.ts b/src/validations/auth.validation.ts index 4687ece..66807b9 100644 --- a/src/validations/auth.validation.ts +++ b/src/validations/auth.validation.ts @@ -7,14 +7,14 @@ import type { export const signupSchema = { body: Joi.object().keys({ email: Joi.string().required().email(), - password: Joi.string().required().min(6), - username: Joi.string().required().min(2) + password: Joi.string().required().min(6).max(150), + username: Joi.string().required().min(2).max(50) }) }; export const loginSchema = { body: Joi.object().keys({ email: Joi.string().required().email(), - password: Joi.string().required().min(6) + password: Joi.string().required().min(6).max(150) }) }; diff --git a/src/validations/password.validation.ts b/src/validations/password.validation.ts index a7becab..3a0a17e 100644 --- a/src/validations/password.validation.ts +++ b/src/validations/password.validation.ts @@ -9,9 +9,11 @@ export const forgotPasswordSchema = { export const resetPasswordSchema = { body: Joi.object().keys({ - newPassword: Joi.string().required().min(6) + newPassword: Joi.string().required().min(6).max(150) }), params: Joi.object().keys({ - token: Joi.string().required().min(1) + token: Joi.string().regex( + /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+/=]*$/ + ) }) }; diff --git a/src/validations/verifyEmail.validation.ts b/src/validations/verifyEmail.validation.ts index 7eea238..773f5f4 100644 --- a/src/validations/verifyEmail.validation.ts +++ b/src/validations/verifyEmail.validation.ts @@ -9,6 +9,8 @@ export const sendVerifyEmailSchema = { export const verifyEmailSchema = { params: Joi.object().keys({ - token: Joi.string().required().min(1) + token: Joi.string().regex( + /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_.+/=]*$/ + ) }) };