-
-
Notifications
You must be signed in to change notification settings - Fork 21.7k
Closed
Description
I was reading up in the API Reference under app.param() and I was interested in using it "…to effectively validate parameters, or also parse them to provide capture groups…". When I copy and paste the code example in it logs an error. I'm running express 3.0.0beta7
Code:
app.param('range', /^(\w+)\.\.(\w+)?$/);
app.get('/range/:range', function(req, res){
var range = req.params.range;
res.send('from ' + range[1] + ' to ' + range[2]);
});
Error:
/Users/thomas/Desktop/node/platform/node_modules/express/lib/router/index.js:67
throw new Error('invalid param() call for ' + name + ', got ' + fn);
^
Error: invalid param() call for range, got /^(\w+)\.\.(\w+)?$/
at Router.param (/Users/thomas/Desktop/node/platform/node_modules/express/lib/router/index.js:67:11)
at app.param (/Users/thomas/Desktop/node/platform/node_modules/express/lib/application.js:232:20)
at Array.forEach (native)
at Function.app.param (/Users/thomas/Desktop/node/platform/node_modules/express/lib/application.js:231:9)
at Object.<anonymous> (/Users/thomas/Desktop/node/platform/app.js:47:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Metadata
Metadata
Assignees
Labels
No labels