Figured it out. Anyone who needs to define $jsonSchema validation on their Mongo collections can issue a command like the following:
# Create the collection by inserting a record
Mongo.insert_one(mongo_pid(), "phones", %{"phone" => "888-555-1212", "name" => "Example"})
# Modify the collection
cmd = [
collMod: "phones",
validator: [
[
json_schema: %{
bson_type: "object",
required: ["phone"]
}
]
]
]
Mongo.command(mongo_pid(), cmd)
Remember: you can only use collMod on an existing collection! Insert a document there (or maybe create an index?) to get the collection created so you can modify it.
Note: the above code uses the mongo_pid() function to retrieve the proper process.