Document Validation
You can set validation rules for collections for updates and inserts.
The validator object consists out of MongoDB-Query-Operators.
// validator object
{ $or:
[
{ phone: { $type: "string" } },
{ email: { $regex: /@mongodb\.com$/ } },
{ status: { $in: [ "Unknown", "Incomplete" ] } }
]
}
Additionally you can set the validation level and a validation action, which determine the behaviour of MongoDB in case the updates and inserts don't respect the validation rules.