In my website's routes file, I have a function like this:
router.post('/', ctrl1.validate, ctrl2.doSomething)
With the validate function looking like this:
function(req,res,next){
var errors = validator.checkForm('myForm')
if(errors){
res.redirect("/")
}else{
next()
}
}
If I want to pass parameters into the validator function (like the name of forms I want to validate) besides the implied req,res,next
, how is that done? I have tried ctrl1.validate(formName)
and ctrl1.validate(formName, req,res,next)
with function(formName, req,res,next)
in the controller, and neither work.