title: Is it possible to set the MongoDb validator as such that undefined properties are not inserted?
body: <p>I am trying to implement a database using MongoDB for my REST API that would be able to store and retrieve documents with specific fields.</p>
  
  <p>I can easily use mongoose but I wish to use MongoDB's native driver, as I want to learn MongoDB rather than mongoose.</p>
  
  <pre><code>    {
        "$jsonSchema": {
         "bsonType": "object",
         "required": [
            "name",
            "email"
          ],
          "properties": {
            "name": {
              "bsonType": "string"
            },
            "email": {
            "bsonType": "string"
            },
            "profileImagePath": {
              "bsonType": "string"
            },
            "blogs": {
              "bsonType": ["object"]
            }
          }
        }
      }
  </code></pre>
  
  <p>I am expecting to only be able to insert data such as </p>
  
  <pre><code>   "name" : "john",
     "email" : "john@gmail.com"
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>   "name" : "john",
     "email" : "john@gmail.com",
     "profileImagePath" : "somePath"
  </code></pre>
  
  <p>but not</p>
  
  <pre><code>   "name" : "john",
     "email" : "john@gmail.com",
     "height" : "5'11"
  </code></pre>
  
  <p>As height has not been specified in the properties.</p>