title: mongoose schema set max length for a String
body: <p>I'm doing a schema with mongoose in Nodejs. And I'm trying to find a way to limit the number of character in a <a href="http://mongoosejs.com/docs/api.html#schema-string-js" rel="noreferrer">SchemaString</a>. I found that it is possible to use a regex with the keyword <em>match</em> like :</p>
  
  <pre><code>var schema = new Schema({
  {
      name: {type: String, match: '/^.{0,20}$/'}
  });
  </code></pre>
  
  <p>But I just want to know if there is some parameter to directly specify a <em>maximum length</em>, like this :</p>
  
  <pre><code>var schema = new Schema({
  {
      name: {type: String, max: 20}
  });
  </code></pre>
  
  <p>Thank you for your help.</p>