Posted On: Sep 25, 2023
Amazon DocumentDB now supports schema validation with $jsonSchema operator. You can now attach schema validation rules to a DocumentDB collection that are validated during inserts and updates to the collection.
Amazon DocumentDB supports a flexible JSON document model; that means documents in a collection can have different fields or data types. Using JSON schema validation, you can now specify schema rules such as field datatypes or required fields for collection having schema requirements e.g., sensor reading datatype as Double or a required email address field. You can also configure the validation rule to check the documents during inserts and updates or only valid and new documents that are added after the schema validation rule was created.
Schema validation is available in Amazon DocumentDB 5.0 and 4.0 instance-based clusters and in all regions in which Amazon DocumentDB is currently present. To create collections with schema validations, please see Getting Started with Schema Validation.