diff options
| author | Waref Haque <warefhaque@Warefs-MacBook-Pro.local> | 2016-07-26 05:05:05 +0000 |
|---|---|---|
| committer | Waref Haque <warefhaque@Warefs-MacBook-Pro.local> | 2016-07-26 05:05:05 +0000 |
| commit | 41f71c1ae22ecb59530a81275b2090300925f924 (patch) | |
| tree | 63112aeb597f97132b4511a438eebd7d89f8a6ea /routes | |
| parent | 91a62e2808bdb17f787a5b234599c838d4fd5220 (diff) | |
searchbar validation
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/index.js | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/routes/index.js b/routes/index.js index f71bc74..3c21216 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,10 +2,8 @@ var dbFile = require("../node_simple.js"); var express = require('express'); var router = express.Router(); var csrf = require('csurf'); // Cross-Site Request Forgery prevention -var express_validator = require("express-validator"); var csrfProtection = csrf(); router.use(csrfProtection); // router is protected -router.use(express_validator); // Remove later var passport_file = require('../config/passport.js'); var bcrypt = require('bcrypt-nodejs'); @@ -61,8 +59,7 @@ router.get('/user_solutions', function(req, res, next) { */ router.get('/exams/', function(req,res,next){ - req.check('search','Course code should be between 6 and 20 characters').notEmpty().withMessage('Course code required').isLength({min: 6, max: 20}); - + req.checkParams('id','Course code should be between 6').notEmpty().withMessage('Course code required').isLength({min: 6, max: 6}); var errors = req.validationErrors(); if (errors){ console.log(errors); @@ -74,7 +71,7 @@ router.get('/exams/', function(req,res,next){ router.get('/exams/:id', function(req, res, next) { - req.check('search','Course code should be between 6 and 20 characters').notEmpty().withMessage('Course code required').isLength({min: 6, max: 20}); + req.checkParams('id','Course code should be between 6 characters').notEmpty().withMessage('Course code required').isLength({min: 6, max: 6}); var errors = req.validationErrors(); if (errors){ |
