How important is it to validate a route? e.g. to serve a 404 if a route parameter is garbage?
I have written the following code
router.post('/questions/:qid/answers/:answerid/vote-:dir', (req, res, next) => {
if (req.params.dir !== ("up" || "down")) {
var error = new Error("π Not Found π");
error.status = 404;
next(error);
}
else if (isNaN(parseInt(req.params.answerid, 10))) {
var error = new Error("NOT FOUND!");
error.status = 404;
next(error);
}
else { next(); }
} , (req, res) => {
// actual response
});
Is this standard practice or do most people not bother?