Synced password validation between frontend and backend
This commit is contained in:
1 parent
65ad8431d8
commit
abf60cfca5
1 file changed
+47
-9
@@ -6,14 +6,30 @@ const joi = require("joi");
|
|||||||
|
|
||||||
const loginValidation = joi.object({
|
const loginValidation = joi.object({
|
||||||
email: joi.string().email().required(),
|
email: joi.string().email().required(),
|
||||||
password: joi.string().min(8).required(),
|
password: joi
|
||||||
|
.string()
|
||||||
|
.min(8)
|
||||||
|
.required()
|
||||||
|
.pattern(
|
||||||
|
new RegExp(
|
||||||
|
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()])[A-Za-z0-9!@#$%^&*()]+$"
|
||||||
|
)
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const registerValidation = joi.object({
|
const registerValidation = joi.object({
|
||||||
firstname: joi.string().required(),
|
firstname: joi.string().required().pattern(new RegExp("^[A-Za-z]+$")),
|
||||||
lastname: joi.string().required(),
|
lastname: joi.string().required().pattern(new RegExp("^[A-Za-z]+$")),
|
||||||
email: joi.string().email().required(),
|
email: joi.string().email().required(),
|
||||||
password: joi.string().min(8).required(),
|
password: joi
|
||||||
|
.string()
|
||||||
|
.min(8)
|
||||||
|
.required()
|
||||||
|
.pattern(
|
||||||
|
new RegExp(
|
||||||
|
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()])[A-Za-z0-9!@#$%^&*()]+$"
|
||||||
|
)
|
||||||
|
),
|
||||||
profileImage: joi.any(),
|
profileImage: joi.any(),
|
||||||
role: joi.string().required(),
|
role: joi.string().required(),
|
||||||
});
|
});
|
||||||
@@ -23,11 +39,25 @@ const editUserParamValidation = joi.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const editUserBodyValidation = joi.object({
|
const editUserBodyValidation = joi.object({
|
||||||
firstname: joi.string(),
|
firstname: joi.string().pattern(new RegExp("^[A-Za-z]+$")),
|
||||||
lastname: joi.string(),
|
lastname: joi.string().pattern(new RegExp("^[A-Za-z]+$")),
|
||||||
profileImage: joi.any(),
|
profileImage: joi.any(),
|
||||||
newPassword: joi.string().min(8),
|
newPassword: joi
|
||||||
password: joi.string().min(8),
|
.string()
|
||||||
|
.min(8)
|
||||||
|
.pattern(
|
||||||
|
new RegExp(
|
||||||
|
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()])[A-Za-z0-9!@#$%^&*()]+$"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
password: joi
|
||||||
|
.string()
|
||||||
|
.min(8)
|
||||||
|
.pattern(
|
||||||
|
new RegExp(
|
||||||
|
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()])[A-Za-z0-9!@#$%^&*()]+$"
|
||||||
|
)
|
||||||
|
),
|
||||||
deleteProfileImage: joi.boolean(),
|
deleteProfileImage: joi.boolean(),
|
||||||
role: joi.string(),
|
role: joi.string(),
|
||||||
});
|
});
|
||||||
@@ -45,7 +75,15 @@ const recoveryTokenValidation = joi.object({
|
|||||||
|
|
||||||
const newPasswordValidation = joi.object({
|
const newPasswordValidation = joi.object({
|
||||||
recoveryToken: joi.string().required(),
|
recoveryToken: joi.string().required(),
|
||||||
password: joi.string().min(8).required(),
|
password: joi
|
||||||
|
.string()
|
||||||
|
.min(8)
|
||||||
|
.required()
|
||||||
|
.pattern(
|
||||||
|
new RegExp(
|
||||||
|
"^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*()])[A-Za-z0-9!@#$%^&*()]+$"
|
||||||
|
)
|
||||||
|
),
|
||||||
confirm: joi.string(),
|
confirm: joi.string(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user