title: Express Router param validation
body: <p>The express 4x api docs claim that you can pass regex as a second argument to <a href="http://expressjs.com/4x/api.html#router.param" rel="noreferrer"><code>router.param</code></a> in order validate params.</p>
  
  <blockquote>
    <p>The method could now be used to effectively validate parameters (and
    optionally parse them to provide capture groups)</p>
  </blockquote>
  
  <p>It then provides the following examples.</p>
  
  <pre><code>// validation rule for id: should be one or more digits
  router.param('id', /^\d+$/);
  
  router.get('/user/:id', function(req, res) {
    res.send('user ' + req.params.id);
  });
  
  // validation rule for range: should start with one more alphanumeric characters, followed by two dots, and end with one more alphanumeric characters
  router.param('range', /^(\w+)\.\.(\w+)?$/);
  
  router.get('/range/:range', function(req, res) {
    var range = req.params.range;
    res.send('from ' + range[1] + ' to ' + range[2]);
  });
  </code></pre>
  
  <p>But, this doesn't actually seem to work. Taking a deeper dive, it doesn't look as if the <a href="https://github.com/strongloop/express/blob/4.x/lib/router/index.js#L84-L114" rel="noreferrer">express code</a> actually supports what the docs claim. In fact, passing anything other than a function will get you a tidy <code>invalid param() call</code> exception.</p>
  
  Using
  
  <p>express <code>4.12.3</code><br />
  node <code>0.12.4</code></p>
  
  <p>So my question is whether this functionality actually exists or if I'm doing something wrong. I'm trying to accomplish the same thing provided in the doc but am receiving the error mentioned above. Any guidance would be greatly appreciated :)</p>