title: Express Req.Body Validation
body: <p>I want to create a piece of express middleware looks something like this:</p>
  
  <pre><code>function validate (options) {
    var defaultOptions = {...}
    , validations = _.extend(defaultOptions, options);
    return validate (req, res, next) {
        /* Use some sort of validation framework where I can pass `validations` into*/
  
  
  
        next(someErrors || null)
    }    
  }
  </code></pre>
  
  <p>I've looked at both <a href="https://github.com/chriso/node-validator">node-validator</a> with the middleware option as well as <a href="https://github.com/agilemd/tracery">tracery</a> but neither of them  looked like you could pass a "rule set" into them and have them run the rules against a provided input. </p>
  
  <p>Does anyone have any suggestions on how to do this with either of those modules or with another one that I haven't found yet? Am I going to have to roll my own to do this?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This is indeed to validate form posts. I know there won't be a single piece of middleware that will cover all of the posts for the whole site; this will be used only for certain routes. I want reusable middleware because we are making APIs that have common routes and expect common form bodies that we want to validate in similar fashion with the option to tweak that on a per API basis.</p>