MongoDB TutorialLesson 23Free preview
MongoDB Validation
This lesson is part of MongoDB · All levels
Summary
This lesson discusses schema validation, a feature that limits the form of a document that can be entered into a collection. You can add validator options when createCollection() or collMod() is a JSON Schema that sets the type, range, and binding of a field. The level of rigidity is set with the validationLevel and the action when invalid is set with the validationAction.
Key points
- Validator is defined by JSON Schema in the collection option
- The validation level governs how strict the rules are applied
- ValidationAction specifies an error or warning when a document is invalid
- Validation can be added via createCollection or collMod
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.