Interface Validator
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 Summary
Modifier and TypeMethodDescriptionstatic Validator
criteria
(CriteriaDefinition criteria) Creates a newValidator
checking documents against a given query structure expressed byCriteriaDefinition
.static Validator
document
(org.bson.Document validationRules) Creates a basicValidator
checking documents against a given set of rules.static Validator
schema
(MongoJsonSchema schema) Creates a newValidator
checking documents against the structure defined inMongoJsonSchema
.org.bson.Document
Get theDocument
containing the validation specific rules.
-
Method Details
-
toDocument
org.bson.Document toDocument()Get theDocument
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
Creates a basicValidator
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
Creates a newValidator
checking documents against the structure defined inMongoJsonSchema
.- Parameters:
schema
- must not be null.- Returns:
- new instance of
Validator
. - Throws:
IllegalArgumentException
- if schema is null.
-
criteria
Creates a newValidator
checking documents against a given query structure expressed byCriteriaDefinition
.- Parameters:
criteria
- must not be null.- Returns:
- new instance of
Validator
. - Throws:
IllegalArgumentException
- if criteria is null.
-