Loading...
Searching...
No Matches
mongocxx::validation_criteria Class Reference

`#include <mongocxx/v_noabi/mongocxx/validation_criteria.hpp>`

## Description

Supports creating validation rules for fields.

Deprecated
  To be removed in an upcoming major release. Set schema validation options as fields of a BSON document passed as an options argument to a MongoDB command instead.

See also
  - Schema Validation

## Public Types

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

## Public Member Functions

bsoncxx::v_noabi::stdx::optional< validation_action > const & | action () const
| Gets the validation action to run when documents failing validation are inserted or modified.
validation_criteria & | action (validation_action action)
| Sets a validation action to run when documents failing validation are inserted or modified.
bsoncxx::v_noabi::stdx::optional< validation_level > const & | level () const
| Gets the validation level.
validation_criteria & | level (validation_level level)
| Sets a validation level.
| operator bsoncxx::v_noabi::document::value () const
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | rule () const
| Gets the validation rule for this validation object.
validation_criteria & | rule (bsoncxx::v_noabi::document::view_or_value rule)
| Sets a validation rule for this validation object.
bsoncxx::v_noabi::document::value | to_document () const
| Returns a bson document representing this set of validation criteria.

## Related Symbols

(Note that these are not member symbols.)
bool | operator== (validation_criteria const &lhs, validation_criteria const &rhs)
| Compare equal when the arguments' rule, level, and action compare equal; otherwise, compare false.
bool | operator!= (validation_criteria const &lhs, validation_criteria const &rhs)
| Compare equal when the arguments' rule, level, and action compare equal; otherwise, compare false.

## Member Enumeration Documentation

## validation_action

enum class mongocxx::v_noabi::validation_criteria::validation_action

strong

A class to represent the different validation action options.

Enumerator
k_error | Reject any insertion or update that violates the validation criteria.
k_warn | Log any violations of the validation criteria, but allow the insertion or update to proceed.

## validation_level

enum class mongocxx::v_noabi::validation_criteria::validation_level

strong

A class to represent the different validation level options.

Enumerator
k_off | Disable validation entirely.
k_moderate | Apply validation rules to inserts, and apply validation rules to updates only if the document to be updated already fulfills the validation criteria.
k_strict | Apply validation rules to all inserts and updates.

## Member Function Documentation

## action() [1/2]

bsoncxx::v_noabi::stdx::optional< validation_action > const & mongocxx::v_noabi::validation_criteria::action | ( |  | ) | const

Gets the validation action to run when documents failing validation are inserted or modified.

Returns
  The enumerated validation action.

## action() [2/2]

validation_criteria & mongocxx::v_noabi::validation_criteria::action | ( | validation_action | action | ) |

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

Parameters

  action | An enumerated validation action.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

## level() [1/2]

bsoncxx::v_noabi::stdx::optional< validation_level > const & mongocxx::v_noabi::validation_criteria::level | ( |  | ) | const

Gets the validation level.

Returns
  The enumerated validation level.

## level() [2/2]

validation_criteria & mongocxx::v_noabi::validation_criteria::level | ( | validation_level | level | ) |

Sets a validation level.

Parameters

  level | An enumerated validation level.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

## operator bsoncxx::v_noabi::document::value()

mongocxx::v_noabi::validation_criteria::operator bsoncxx::v_noabi::document::value | ( |  | ) | const

inline

Deprecated
  This method is deprecated. To determine which options are set on this object, use the provided accessors instead.

## rule() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & mongocxx::v_noabi::validation_criteria::rule | ( |  | ) | const

Gets the validation rule for this validation object.

Returns
  Document representing a validation rule.

## rule() [2/2]

validation_criteria & mongocxx::v_noabi::validation_criteria::rule | ( | bsoncxx::v_noabi::document::view_or_value | rule | ) |

Sets a validation rule for this validation object.

Parameters

  rule | Document representing a validation rule.

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

## to_document()

bsoncxx::v_noabi::document::value mongocxx::v_noabi::validation_criteria::to_document | ( |  | ) | const

Returns a bson document representing this set of validation criteria.

Deprecated
  This method is deprecated. To determine which options are set on this object, use the provided accessors instead.

Returns
  Validation criteria, as a document.

## Friends And Related Symbol Documentation

## operator!=()

bool operator!= | ( | validation_criteria const & | lhs,
|  | validation_criteria const & | rhs )

related

Compare equal when the arguments' rule, level, and action compare equal; otherwise, compare false.

## operator==()

bool operator== | ( | validation_criteria const & | lhs,
|  | validation_criteria const & | rhs )

related

Compare equal when the arguments' rule, level, and action compare equal; otherwise, compare false.

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

- mongocxx/v_noabi/mongocxx/validation_criteria.hpp