For existing data, we want to allow the application to continue to operate as we introduce validation into our collections.
Therefore, we want to allow updates and simply log failed validations so we can take corrective measures separately if necessary, or take no action.
You get the best of both worlds – a dynamic schema for rapidly changing, polymorphic data, with the option to enforce strict validation checks against specific attributes from the onset of your project, or much later on.
In our case, we'll use the example of an XML document, Xml Document Url, that contains an As I explained previously, an XML Schemain our example, Schema Urldefines the structure of an XML document.
This is possible, but in more agile approaches, the first version may deploy with no validations and future releases will add new data and checks.
Fortunately, Mongo DB 3.2 provides a great deal of flexibility in this area.
For any key it might be appropriate to check: Further, it may be necessary to combine these checks – for example that the document contains the user's name and either their email address or phone number, and if the email address does exist, then it must be correctly formed.
Adding the validation checks to a collection is very intuitive to any developer or DBA familiar with Mongo DB as it uses the same expression syntax as a Proponents of the waterfall development processes would assert that all of the validations should be added right at the start of the project – certainly before going into production.