Skip to content

Commit

Permalink
Enhanced joi validation closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Louis3797 committed Nov 9, 2024
1 parent 50ac4b1 commit 1b73905
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/validations/auth.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import type {
export const signupSchema = {
body: Joi.object<UserSignUpCredentials>().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<UserLoginCredentials>().keys({
email: Joi.string().required().email(),
password: Joi.string().required().min(6)
password: Joi.string().required().min(6).max(150)
})
};
6 changes: 4 additions & 2 deletions src/validations/password.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-_.+/=]*$/
)
})
};
4 changes: 3 additions & 1 deletion src/validations/verifyEmail.validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-_.+/=]*$/
)
})
};

0 comments on commit 1b73905

Please sign in to comment.