title: How to require a nested json object in Mongoose Schema
body: <p>I have the following mongoose schema:</p>
  
  <pre><code>const productSchema = new mongoose.Schema({
    name: {
      type: String,
      required: true,
      minlength: 1,
      maxlength: 255
    },
    extraData: {
      brand: {
        type: String,
        required: true,
        minlength: 1,
        maxlength: 255
      },
      quantity: {
        type: Number,
        required: true,
        minlength: 1,
        maxlength: 10
      },
     required: true
    }
  });
  </code></pre>
  
  <p>However when i execute it I get the following error: "TypeError: Invalid schema configuration: <code>True</code> is not a valid type at path <code>extraData.required</code>". How can I require the extraData?</p>