Package com.mongodb.client.model
Class ValidationOptions
- java.lang.Object
-
- com.mongodb.client.model.ValidationOptions
-
public final class ValidationOptions extends Object
Validation options for documents being inserted or updated in a collection- Since:
- 3.2
- MongoDB documentation
- Create Collection
- Since server release
- 3.2
-
-
Constructor Summary
Constructors Constructor Description ValidationOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ValidationActiongetValidationAction()Gets theValidationAction.ValidationLevelgetValidationLevel()Gets theValidationLevelthat determines how strictly MongoDB applies the validation rules to existing documents during an insert or update.BsongetValidator()Gets the validation rules if set or null.StringtoString()ValidationOptionsvalidationAction(ValidationAction validationAction)Sets theValidationActionthat determines whether to error on invalid documents or just warn about the violations but allow invalid documents.ValidationOptionsvalidationLevel(ValidationLevel validationLevel)Sets the validation level that determines how strictly MongoDB applies the validation rules to existing documents during an insert or update.ValidationOptionsvalidator(Bson validator)Sets the validation rules for all
-
-
-
Method Detail
-
getValidator
@Nullable public Bson getValidator()
Gets the validation rules if set or null.- Returns:
- the validation rules if set or null
-
validator
public ValidationOptions validator(@Nullable Bson validator)
Sets the validation rules for all- Parameters:
validator- the validation rules- Returns:
- this
-
getValidationLevel
@Nullable public ValidationLevel getValidationLevel()
Gets theValidationLevelthat determines how strictly MongoDB applies the validation rules to existing documents during an insert or update.- Returns:
- the ValidationLevel.
-
validationLevel
public ValidationOptions validationLevel(@Nullable ValidationLevel validationLevel)
Sets the validation level that determines how strictly MongoDB applies the validation rules to existing documents during an insert or update.- Parameters:
validationLevel- the validation level- Returns:
- this
-
getValidationAction
@Nullable public ValidationAction getValidationAction()
Gets theValidationAction.- Returns:
- the ValidationAction.
-
validationAction
public ValidationOptions validationAction(@Nullable ValidationAction validationAction)
Sets theValidationActionthat determines whether to error on invalid documents or just warn about the violations but allow invalid documents.- Parameters:
validationAction- the validation action- Returns:
- this
-
-