Interface MongoJsonSchema


public interface MongoJsonSchema
Interface defining MongoDB-specific JSON schema object. New objects can be built with builder(), for example:
 MongoJsonSchema schema = MongoJsonSchema.builder().required("firstname", "lastname")
                .properties(string("firstname").possibleValues("luke", "han"),
                                object("address").properties(string("postCode").minLength(4).maxLength(5))

                ).build();
 
resulting in the following schema:
  {
  "type": "object",
  "required": [ "firstname", "lastname" ],
  "properties": {
    "firstname": {
      "type": "string", "enum": [ "luke", "han" ],
    },
    "address": {
      "type": "object",
      "properties": {
        "postCode": { "type": "string", "minLength": 4, "maxLength": 5 }
      }
    }
  }
}
 
Since:
2.1
Author:
Christoph Strobl, Mark Paluch
See Also: