-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #71 from buildingu/FE-feature-add-forgot-password-…
…page Fe feature add forgot password page
- Loading branch information
Showing
8 changed files
with
281 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,40 @@ | ||
module.exports = (input) => { | ||
let errors = {}; | ||
let emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; | ||
|
||
if (!input) { | ||
return { | ||
errors: { msg: "Input is required" }, | ||
validationCheck: false, | ||
}; | ||
} | ||
|
||
for (let [key, value] of Object.entries(input)) { | ||
if (typeof value !== "string") { | ||
errors[key] = `email and password must be a string`; | ||
} | ||
} | ||
|
||
if (input.newPassword.length <= 0 || input.username.length <= 0) { | ||
errors.field = "Password and or email Field Cannot be empty"; | ||
} | ||
|
||
if (input.newPassword.length < 8) { | ||
errors.password = "Password must be at least 8 characters long"; | ||
} | ||
|
||
if (input.newPassword.length > 30) { | ||
errors.password = "Password cannot be more than 30 characters long"; | ||
} | ||
|
||
if (!emailPattern.test(input.username)) { | ||
errors.email = "email is not valid"; | ||
} | ||
|
||
let validationCheck = !Object.keys(errors).length ? true : false; | ||
|
||
let errors = {}; | ||
let emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/; | ||
|
||
if (!input) { | ||
return { | ||
errors, | ||
validationCheck, | ||
errors: { msg: "Input is required" }, | ||
validationCheck: false, | ||
}; | ||
} | ||
|
||
for (let [key, value] of Object.entries(input)) { | ||
if (typeof value !== "string") { | ||
errors[key] = `email and password must be a string`; | ||
} | ||
} | ||
|
||
if (input.newPassword.length <= 0 || input.username.length <= 0) { | ||
errors.field = "Password and or email Field Cannot be empty"; | ||
} | ||
|
||
if (input.newPassword.length < 8) { | ||
errors.password = "Password must be at least 8 characters long"; | ||
} | ||
|
||
if (input.newPassword.length > 30) { | ||
errors.password = "Password cannot be more than 30 characters long"; | ||
} | ||
|
||
if (!emailPattern.test(input.username)) { | ||
errors.email = "email is not valid"; | ||
} | ||
|
||
let validationCheck = !Object.keys(errors).length ? true : false; | ||
|
||
return { | ||
errors, | ||
validationCheck, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.