diff --git a/Client/src/Components/TabPanels/ProfileSettings/ProfilePanel.jsx b/Client/src/Components/TabPanels/ProfileSettings/ProfilePanel.jsx index 2675aedd9..14a3ba1b0 100644 --- a/Client/src/Components/TabPanels/ProfileSettings/ProfilePanel.jsx +++ b/Client/src/Components/TabPanels/ProfileSettings/ProfilePanel.jsx @@ -153,7 +153,7 @@ const ProfilePanel = () => {
- First Name + First name @@ -178,7 +178,7 @@ const ProfilePanel = () => {
- Last Name + Last name @@ -232,18 +232,17 @@ const ProfilePanel = () => {
- Your Photo + Your photo This photo will be displayed in your profile page. - {/* TODO - Update placeholder values with redux data */} { + if (!/[A-Z]/.test(value)) { + return helpers.message( + "*Password must contain at least one uppercase letter." + ); + } + if (!/[a-z]/.test(value)) { + return helpers.message( + "*Password must contain at least one lowercase letter." + ); + } + if (!/\d/.test(value)) { + return helpers.message("*Password must contain at least one number."); + } + if (!/[!@#$%^&*]/.test(value)) { + return helpers.message( + "*Password must contain at least one special character." + ); + } + + return value; + }); + const editPasswordValidation = joi.object({ // TBD - validation for current password ? - password : joi - .string().trim() - .messages({ - "string.empty": "*Current password is required.", - }), - newpassword: joi - .string() - .trim() - .min(8) - .messages({ - "string.empty": "*Password is required.", - "string.min": "*Password must be at least 8 characters long.", - }) - .custom((value, helpers) => { - if (!/[A-Z]/.test(value)) { - return helpers.message( - "*Password must contain at least one uppercase letter." - ); - } - if (!/[a-z]/.test(value)) { - return helpers.message( - "*Password must contain at least one lowercase letter." - ); - } - if (!/\d/.test(value)) { - return helpers.message("*Password must contain at least one number."); - } - if (!/[!@#$%^&*]/.test(value)) { - return helpers.message( - "*Password must contain at least one special character." - ); - } - - return value; - }), + password: passwordSchema, + newpassword: passwordSchema, confirm: joi .string() .trim() @@ -126,8 +124,8 @@ const editPasswordValidation = joi.object({ "string.empty": "*Password confirmation is required.", }) .custom((value, helpers) => { - const { password } = helpers.prefs.context; - if (value !== password) { + const { newpassword } = helpers.prefs.context; + if (value !== newpassword) { return helpers.message("*Passwords do not match."); } return value;