This will add the ability for users to configure a match expression on collections that all new
documents and updates to existing documents must match. An attempt to create a document that doesn't
match the validation will fail with error code 121 (DocumentValidationFailure).
Validators can be set by passing the 'validator' option to the 'create' command. They can also be
changed or added by passing a 'validator' option to the 'collMod' command. Passing
validator: {} (a query that matches all documents) removes the validator from a collection. When a
validator is set on a collection we only validate new objects, not existing objects.
The following commands will support a new flag 'bypassDocumentValidation' which allows opting out of
validation on a per-operation basis, for example when restoring potentially invalid data from a
backup. This will require a new BypassDocumentValidation permission which is granted to the built-in
roles 'restore' and 'dbadmin'.
- applyOps
- clone
- cloneCollection
- copyDb
- findAndModify
- mapReduce
- insert (only as command)
- update (only as command)
- aggregate (for $out)
- is related to
-
DRIVERS-250 Support bypassDocumentValidation
- Closed
- related to
-
SERVER-20783 aggregate $out + validator error: wrong error code
- Closed