title: SailsJS - How to specify string attribute length without getting error when creating record?
body: <p>I'm using Sails 0.9.8 paired with MySQL and wanting to do something like this</p>
  
  <pre><code>localhost:1337/player/view/&lt;username of player&gt;
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>localhost:1337/player/view/&lt;id of player&gt;
  </code></pre>
  
  <p>So I put something like this in the model:</p>
  
  <pre><code>'username' : {
          type: 'string',
          unique: true,
          minLength: 4,
          maxLength: 32,
          required: true
      },
  </code></pre>
  
  <p>But I've got an error whenever I run sails lift:</p>
  
  <pre><code>{ [Error: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes] code: 'ER_TOO_LONG_KEY', index: 0 }
  </code></pre>
  
  <p>So after I run through the modules, I discovered that it was because by default Sails give string-type attribute a length of 255 in the database. The given length can be overridden with 'size', but it causes another error when creating a record.</p>
  
  <pre><code>'username' : {
          type: 'string',
          unique: true,
          minLength: 4,
          maxLength: 32,
          size: 32,
          required: true
      },
  </code></pre>
  
  <p>The error caused when creating a record:</p>
  
  <pre><code>Error: Unknown rule: size
  at Object.match (&lt;deleted&gt;npm\node_modules\sails\node_modules\waterline\node_modules\anchor\lib\match.js:50:9)
  at Anchor.to (&lt;deleted&gt;\npm\node_modules\sails\node_modules\waterline\node_modules\anchor\index.js:76:45)
  at &lt;deleted&gt;\npm\node_modules\sails\node_modules\waterline\lib\waterline\core\validations.js:137:33
  </code></pre>
  
  <p>The question is, how do I specify the size of the string column (so that I can use the unique key) without getting an error when creating a record?</p>