title: Pymongo.db.create_collection with validator returns 'unknown operator: $jsonSchema'
body: <p>I am trying to create a schema for my <code>mongoDB</code> database in order to ensure data format in the Database.</p>
  <p>I am using <code>pymongo</code> to make sure this happens in my docker container when application starts, if the database is not initialized.</p>
  <pre class="lang-py prettyprint-override"><code>self.client = MongoClient(conn_string)
  self.db = self.client[db_name]
  # ...
  # I am looping over in my json and 'stuff' is the collection name
  # and json['stuff'] is the schema, so:
  # collection = 'stuff'
  # schema = json[collection]
  # ... 
  self.db.create_collection(collection, validator= { &quot;validator&quot;: { &quot;$jsonSchema&quot;: schema} })
  
  </code></pre>
  <p>The schema looks like that, and is loaded from a <code>json</code> file. (and that work)</p>
  <pre class="lang-json prettyprint-override"><code>{
     &quot;stuff&quot;: {
        &quot;bsonType&quot;: &quot;object&quot;,
        &quot;required&quot;: [ &quot;sid&quot;, &quot;name&quot;, &quot;url&quot; ],
        &quot;properties&quot;: {
           &quot;sid&quot;: {
              &quot;bsonType&quot;: &quot;string&quot;,
              &quot;pattern&quot;: &quot;^[a-z_]{3-20}$&quot;,
              &quot;description&quot;: &quot;must be a string 3-20 lowercase chars and is required&quot;
           },
           &quot;name&quot;: {
              &quot;bsonType&quot;: &quot;string&quot;,
              &quot;minLength&quot;: 2,
              &quot;maxLength&quot;: 30,
              &quot;description&quot;: &quot;must be a string 2-30 chars and is required&quot;
           },
           &quot;url&quot;: {
              // etc.
           }
        }
     }
  }
  </code></pre>
  <p>But I  get this error:</p>
  <pre class="lang-py prettyprint-override"><code>pymongo.errors.OperationFailure: unknown operator: $jsonSchema, full error: 
    {'ok': 0.0, 'errmsg': 'unknown operator: $jsonSchema', 'code': 2, 'codeName': 'BadValue'}
  </code></pre>