Allows you to set a validator, a query that every new or updated document must match

Example with JSON schema:


db.runCommand( {
    collMod: "whisky",
    validator: {
        $jsonSchema: {
            bsonType: "object",
            *required*: [ "name", "age" ],
            properties: {
                name: {
                    *bsonType*: "string",
                    description: "The name of the whisky.",
                },
                age: {
                    bsonType: "int",
                    *minimum: 3,*
                    description: "The age in years of the whisky".
                }
            }
        }
    },
} )