MongoDB C++ Driver  mongocxx-3.0.2
Public Types | Public Member Functions | List of all members
mongocxx::validation_criteria Class Reference

Class representing criteria for document validation, to be applied to a collection. More...

#include <validation_criteria.hpp>

Public Types

enum  validation_level
 A class to represent the different validation level options.
 
enum  validation_action
 A class to represent the different validation action options. More...
 

Public Member Functions

void rule (bsoncxx::document::view_or_value rule)
 Set a validation rule for this validation object. More...
 
void level (validation_level level)
 Set a validation level. More...
 
void action (validation_action action)
 Set a validation action to run when documents failing validation are inserted or modified. More...
 
bsoncxx::document::value to_document () const
 Return a bson document representing this set of validation criteria. More...
 
 operator bsoncxx::document::value () const
 

Detailed Description

Class representing criteria for document validation, to be applied to a collection.

See also
https://docs.mongodb.org/manual/core/document-validation/

Member Enumeration Documentation

A class to represent the different validation action options.

Todo:
document enum values

Member Function Documentation

void mongocxx::validation_criteria::action ( validation_action  action)

Set a validation action to run when documents failing validation are inserted or modified.

Parameters
actionA validation action, either "error" or "warn."
void mongocxx::validation_criteria::level ( validation_level  level)

Set a validation level.

Parameters
levelA validation level, "off," "strict," or "moderate."
mongocxx::validation_criteria::operator bsoncxx::document::value ( ) const
Todo:
document this method
void mongocxx::validation_criteria::rule ( bsoncxx::document::view_or_value  rule)

Set a validation rule for this validation object.

Parameters
ruleDocument representing a validation rule.
bsoncxx::document::value mongocxx::validation_criteria::to_document ( ) const

Return a bson document representing this set of validation criteria.

Returns
Validation criteria, as a document.

The documentation for this class was generated from the following file: