Company
Date Published
Author
Andrew Morgan
Word count
1800
Language
English
Hacker News points
None

Summary

Document Validation in MongoDB 3.2 introduces a new feature that allows developers to enforce rules on what data is stored in the database, providing flexibility and control over document schema without having to define a formal schema upfront. This feature addresses challenges such as ensuring consistency across development teams, vendors, and different applications, while maintaining the benefits of dynamic schema for rapidly changing data. Document Validation provides significant flexibility to customize which parts of documents are validated, including checks on key existence, type, format, and range, making it easy to enforce constraints on specific attributes without impacting performance. While not all data validation can be done in the database, Document Validation excels by providing a simple and flexible way to set up validations without requiring stored procedures or new syntax, allowing developers to ensure data consistency while maintaining agility and scalability.