title: passportjs mongoose model with required field
body: <p>Does anyone know why we cannot define a mongoose model that is used by passport with required field on username, passport, phone, email and name? If I do not write required or use required:false it works fine.</p>
  
  <p>for example this model gives error if you use it in passportjs</p>
  
  <pre><code>    var userSchema=new Schema({
    username:{trype:String},  //As I use directly userSchema in passportJs I cannot use required:true for the files. I do not know hy yet anyhow.
    password:{trype:String},
    name:{trype:String,required:true}
  });
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>throw new TypeError('Undefined type `' + name + '` at `' + path +
  ^
  </code></pre>
  
  <p>TypeError: Undefined type <code>undefined</code> at <code>name.required</code>
    Did you try nesting Schemas? You can only nest using refs or arrays.
      at Function.Schema.interpretAsType (XX\node_modules\mongoose\lib\schema.js:644:11)</p>
  
  <p>Thanks</p>