public interface Validator
Provides a validator object to be used for collection validation via CollectionOptions.ValidationOptions.
Since:
2.1
Author:
Andreas Zink, Christoph Strobl
See Also:
  • Method Details

    • toDocument

      org.bson.Document toDocument()
      Get the Document containing the validation specific rules. The document may contain fields that may require type and/or field name mapping.
      Returns:
      a MongoDB validator Document. Never null.
    • document

      static Validator document(org.bson.Document validationRules)
      Creates a basic Validator checking documents against a given set of rules.
      Parameters:
      validationRules - must not be null.
      Returns:
      new instance of Validator.
      Throws:
      IllegalArgumentException - if validationRules is null.
    • schema

      static Validator schema(MongoJsonSchema schema)
      Creates a new Validator checking documents against the structure defined in MongoJsonSchema.
      Parameters:
      schema - must not be null.
      Returns:
      new instance of Validator.
      Throws:
      IllegalArgumentException - if schema is null.
    • criteria

      static Validator criteria(CriteriaDefinition criteria)
      Creates a new Validator checking documents against a given query structure expressed by CriteriaDefinition.
      Parameters:
      criteria - must not be null.
      Returns:
      new instance of Validator.
      Throws:
      IllegalArgumentException - if criteria is null.