-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#167190529 Validate User Signup Inputs #19
Conversation
expect(res.body.errors).to.haveOwnProperty('password'); | ||
expect(res.body.errors.password).to.match( | ||
/Password should not contain spaces/i | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline before ')' function-paren-newline
expect(res.statusCode).to.equal(422); | ||
expect(res.body).to.haveOwnProperty('errors'); | ||
expect(res.body.errors).to.haveOwnProperty('password'); | ||
expect(res.body.errors.password).to.match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline after '(' function-paren-newline
expect(res.body.errors).to.haveOwnProperty('password'); | ||
expect(res.body.errors.password).to.match( | ||
/Password should not be less than 8 characters/i | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline before ')' function-paren-newline
expect(res.statusCode).to.equal(422); | ||
expect(res.body).to.haveOwnProperty('errors'); | ||
expect(res.body.errors).to.haveOwnProperty('password'); | ||
expect(res.body.errors.password).to.match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline after '(' function-paren-newline
expect(res.body.errors).to.haveOwnProperty('userName'); | ||
expect(res.body.errors.userName).to.match( | ||
/username should contain only letters and numbers/i | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline before ')' function-paren-newline
expect(res.statusCode).to.equal(422); | ||
expect(res.body).to.haveOwnProperty('errors'); | ||
expect(res.body.errors).to.haveOwnProperty('lastName'); | ||
expect(res.body.errors.lastName).to.match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline after '(' function-paren-newline
expect(res.body.errors).to.haveOwnProperty('lastName'); | ||
expect(res.body.errors.lastName).to.match( | ||
/last name should not be less than 2 characters/i | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline before ')' function-paren-newline
expect(res.statusCode).to.equal(422); | ||
expect(res.body).to.haveOwnProperty('errors'); | ||
expect(res.body.errors).to.haveOwnProperty('lastName'); | ||
expect(res.body.errors.lastName).to.match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline after '(' function-paren-newline
expect(res.body.errors).to.haveOwnProperty('firstName'); | ||
expect(res.body.errors.firstName).to.match( | ||
/first name should not be more than 50 characters/i | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline before ')' function-paren-newline
expect(res.statusCode).to.equal(422); | ||
expect(res.body).to.haveOwnProperty('errors'); | ||
expect(res.body.errors).to.haveOwnProperty('firstName'); | ||
expect(res.body.errors.firstName).to.match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline after '(' function-paren-newline
server/helpers/serverResponse.js
Outdated
@@ -0,0 +1,10 @@ | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dinobi, I have updated my PR, and I noticed that the file has been updated on my branch as well. Basically, my local branch is in sync with the remote develop, so this file is no longer a repeated file.
You would notice that this file is no longer in the Files changed
section of this PR.
86945a8
to
20bc37f
Compare
expect(res.body.errors).to.haveOwnProperty('firstName'); | ||
expect(res.body.errors.firstName).to.match( | ||
/first name should not be less than 2 characters/i | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline before ')' function-paren-newline
expect(res.statusCode).to.equal(422); | ||
expect(res.body).to.haveOwnProperty('errors'); | ||
expect(res.body.errors).to.haveOwnProperty('firstName'); | ||
expect(res.body.errors.firstName).to.match( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unexpected newline after '(' function-paren-newline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job @abdulfatai360. Please, could you confirm that your work will throw an error when an unallowed variable is passed into the request body?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, setCustomMessage would have been better placed outside the userSignup.js
so it can be reusable for other input validations such as User Login, etc
@LukasChiama Thank you for your feedback. If you could remember, the decision to prevent an unwanted field from getting pass our validation middleware was why we changed from using According to Joi documentation, the Refer to the link and screenshot below for evidences: |
- install joi validation library - install sinon spies and stubs library - write user signup schemas in a schema/ folder at server/ root - check user signup inouts for validation errors - return validation errors to users [Delivers #167190529]
20bc37f
to
4a1b8f0
Compare
@Adekoreday Thanks for your feedback. What you pointed out will sure improve the code quality of our codebase. I have implemented your feedback. And push the changes to the repo. Thanks, once again. |
.max(254) | ||
.regex(/\s/, { invert: true }) | ||
.error(setCustomMessage('password')) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you include the confirmPassword
field here as well? It is required for a check in the controllers for checking that passwords match.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@LukasChiama I don't think that's part of our User schema
What does this PR do?
Description of Task proposed in this pull request?
schema/userSignup.js
inside the/server
directory@hapi/joi
library to write the schema and validate the signup inputssinon
to help in mockingExpressJs
req
,res
, andnext
objects for unit testing the validation middlewareHow should this be manually tested (Quality Assurance)?
https://github.com/andela/ah-rambo-backend.git
to clone this repo onto your local machinecd ah-rambo-backend/
git status
commandgit fetch origin pull/19/head:ft-validate-user-signup-inputs-167190529
git checkout ft-validate-user-signup-inputs-167190529
npm test
What are the relevant pivotal tracker stories?
Any background context you want to add (Operations Impact)?
npm install
to get all dependencies onto your local machineWhat I have learned working on this feature:
Screenshots: