From 41f71c1ae22ecb59530a81275b2090300925f924 Mon Sep 17 00:00:00 2001 From: Waref Haque Date: Tue, 26 Jul 2016 01:05:05 -0400 Subject: searchbar validation --- routes/index.js | 7 ++----- 1 file 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){ -- cgit v1.2.3