MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
validation_criteria.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
18
21
23
24namespace mongocxx {
25namespace v_noabi {
26
37 public:
49 rule(bsoncxx::v_noabi::document::view_or_value rule);
50
57 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view_or_value> const&)
58 rule() const;
59
74
86
94 level() const;
95
99 enum class validation_action {
102
106 };
107
119
128 action() const;
129
140
141 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::document::value) to_document_deprecated() const;
142
148 MONGOCXX_DEPRECATED operator bsoncxx::v_noabi::document::value() const {
149 return to_document_deprecated();
150 }
151
152 private:
156};
157
163
166operator==(validation_criteria const& lhs, validation_criteria const& rhs);
167
170operator!=(validation_criteria const& lhs, validation_criteria const& rhs);
173
174} // namespace v_noabi
175} // namespace mongocxx
176
177namespace mongocxx {
178
179using ::mongocxx::v_noabi::operator==;
180using ::mongocxx::v_noabi::operator!=;
181
182} // namespace mongocxx
183
185
A polyfill for std::optional<T>.
Definition optional.hpp:800
Supports creating validation rules for fields.
Definition validation_criteria.hpp:36
validation_criteria & rule(bsoncxx::v_noabi::document::view_or_value rule)
Sets a validation rule for this validation object.
validation_criteria & level(validation_level level)
Sets a validation level.
operator bsoncxx::v_noabi::document::value() const
Definition validation_criteria.hpp:148
validation_action
A class to represent the different validation action options.
Definition validation_criteria.hpp:99
@ k_error
Reject any insertion or update that violates the validation criteria.
Definition validation_criteria.hpp:101
@ k_warn
Log any violations of the validation criteria, but allow the insertion or update to proceed.
Definition validation_criteria.hpp:105
validation_level
A class to represent the different validation level options.
Definition validation_criteria.hpp:63
@ k_moderate
Apply validation rules to inserts, and apply validation rules to updates only if the document to be u...
Definition validation_criteria.hpp:69
@ k_strict
Apply validation rules to all inserts and updates.
Definition validation_criteria.hpp:72
@ k_off
Disable validation entirely.
Definition validation_criteria.hpp:65
validation_criteria & action(validation_action action)
Sets a validation action to run when documents failing validation are inserted or modified.
bsoncxx::v_noabi::document::value to_document() const
Returns a bson document representing this set of validation criteria.
Provides bsoncxx::v_noabi::document::view_or_value.
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition export.hpp:25
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Provides std::optional-related polyfills for library API usage.
Declares mongocxx::v_noabi::validation_criteria.