Skip to content

Instantly share code, notes, and snippets.

@ryansobol
Forked from IanSmith89/README.md
Last active September 25, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save ryansobol/7d02bc09fddec3621b463803460dd2b4 to your computer and use it in GitHub Desktop.
Save ryansobol/7d02bc09fddec3621b463803460dd2b4 to your computer and use it in GitHub Desktop.
Galvanize Bookshelf Validations

Server-side Validations for Galvanize Bookshelf

Change into your project directory.

cd galvanize-bookshelf

Ensure the staging area of the master branch is clean. Then, create and checkout a new feature branch.

git checkout -b validations

Install the following NPM packages.

npm install --save joi@^9.0.4 express-validation

Make a new validations directory.

mkdir validations

And create one validation file per route file.

touch validations/authors.js
touch validations/books.js
touch validations/token.js
touch validations/users.js

Then, add rules to validate the req.body of all POST requests for the following route files.

  • routes/authors.js
  • routes/books.js
  • routes/token.js
  • routes/users.js

Bonus

Then, add rules to validate the req.body of all PATCH requests for the following route files.

  • routes/authors.js
  • routes/books.js

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment