Module spring.data.mongodb
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 Validatorcriteria(CriteriaDefinition criteria) Creates a newValidatorchecking documents against a given query structure expressed byCriteriaDefinition.static Validatordocument(org.bson.Document validationRules) Creates a basicValidatorchecking documents against a given set of rules.static Validatorschema(MongoJsonSchema schema) Creates a newValidatorchecking documents against the structure defined inMongoJsonSchema.org.bson.DocumentGet theDocumentcontaining the validation specific rules.
-
Method Details
-
toDocument
org.bson.Document toDocument()Get theDocumentcontaining the validation specific rules. The document may contain fields that may require type and/or field name mapping.- Returns:
- a MongoDB
validatorDocument. Never null.
-
document
Creates a basicValidatorchecking 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 newValidatorchecking 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 newValidatorchecking 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.
-