MongoDB C++ Driver mongocxx-3.11.0
Loading...
Searching...
No Matches
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
22#include <mongocxx/stdx.hpp>
23
25
26namespace mongocxx {
27namespace v_noabi {
28
36 public:
48 rule(bsoncxx::v_noabi::document::view_or_value rule);
49
56 MONGOCXX_ABI_EXPORT_CDECL(const stdx::optional<bsoncxx::v_noabi::document::view_or_value>&)
57 rule() const;
58
62 enum class validation_level {
64 k_off,
65
69
72 };
73
85
93
97 enum class validation_action {
99 k_error,
100
103 k_warn,
104 };
105
117
126
137 to_document() const;
138
139 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::document::value) to_document_deprecated() const;
140
146 MONGOCXX_DEPRECATED operator bsoncxx::v_noabi::document::value() const {
147 return to_document_deprecated();
148 }
149
150 private:
154};
155
161
164operator==(const validation_criteria& lhs, const validation_criteria& rhs);
165
168operator!=(const validation_criteria& lhs, const validation_criteria& rhs);
171
172} // namespace v_noabi
173} // namespace mongocxx
174
175namespace mongocxx {
176
177using ::mongocxx::v_noabi::operator==;
178using ::mongocxx::v_noabi::operator!=;
179
180} // namespace mongocxx
181
183
188
189#if defined(MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
190
191namespace mongocxx {
192
195
198
199} // namespace mongocxx
200
201#endif // defined(MONGOCXX_PRIVATE_DOXYGEN_PREPROCESSOR)
A read-only BSON document that owns its underlying buffer. When a document::value goes out of scope,...
Definition value.hpp:38
A polyfill for std::optional<T>.
Definition optional.hpp:874
Class representing criteria for document validation, to be applied to a collection.
Definition validation_criteria.hpp:35
MONGOCXX_DEPRECATED bsoncxx::v_noabi::document::value to_document() const
Returns a bson document representing this set of validation criteria.
validation_criteria & level(validation_level level)
Sets a validation level.
const stdx::optional< validation_action > & action() const
Gets the validation action to run when documents failing validation are inserted or modified.
validation_action
A class to represent the different validation action options.
Definition validation_criteria.hpp:97
@ 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
A class to represent the different validation level options.
Definition validation_criteria.hpp:62
@ k_moderate
Apply validation rules to inserts, and apply validation rules to updates only if the document to be u...
@ k_strict
Apply validation rules to all inserts and updates.
validation_criteria & action(validation_action action)
Sets a validation action to run when documents failing validation are inserted or modified.
MONGOCXX_DEPRECATED operator bsoncxx::v_noabi::document::value() const
Definition validation_criteria.hpp:146
const stdx::optional< validation_level > & level() const
Gets the validation level.
const stdx::optional< bsoncxx::v_noabi::document::view_or_value > & rule() const
Gets the validation rule for this validation object.
Provides bsoncxx::v_noabi::document::view_or_value.
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition fwd.hpp:258
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition fwd.hpp:222
The mongocxx macro guard postlude header.
The mongocxx macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
The top-level namespace within which all mongocxx library entities are declared.
bool operator!=(const v_noabi::hint &index_hint, std::string index)
mongocxx::v_noabi::operator!=(const v_noabi::hint& index_hint, std::string index)
bool operator==(std::string index, const v_noabi::hint &index_hint)
mongocxx::v_noabi::operator==(std::string index, const v_noabi::hint& index_hint)
Provides std::optional-related polyfills for library API usage.
Redeclares bsoncxx::v_noabi::stdx in mongocxx::v_noabi::stdx for internal use.
Declares mongocxx::v_noabi::validation_criteria.