HackerYou / chalk-api

2 stars 7 forks source link

Server-side validation #126

Open swbloom opened 7 years ago

swbloom commented 7 years ago

Currently, the API will let you create new documents that receive request bodies that are malformed (missing payload data, IDs pointing to instructors that don't exist).

The API should validate requests and reject improperly formatted ones.

swbloom commented 7 years ago

I was looking at different validation strategies for express, and it looks like validation middleware is a common pattern for ensuring properly formatted requests. @Rchristiani what do you think of something like this: https://www.npmjs.com/package/express-validator

My concerns about it is that it might make a lot of our tests fail (though maybe that's a good thing?)

I can put together a proof of concept on a branch if you think it's something worth exploring

Rchristiani commented 7 years ago

Will look into it, but it probably makes more sense to do it via Mongoose http://mongoosejs.com/docs/validation.html