Skip to content
Justice Tech School

Schema Validation

$jsonSchema enforces shape.

Example
db.createCollection("users", {
  validator: { $jsonSchema: {
    required: ["name"],
    properties: { name: { bsonType: "string" } }
  } }
})

Exercise

Validator key.

{ : {} }

Quiz Test

What does validation reject?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.