bsoncxx::document::value validation_criteria::to_document() const { bsoncxx::builder::basic::document doc; if (_rule) { doc.append(kvp("validator", bsoncxx::types::b_document{*_rule})); } if (_level) { doc.append(kvp("validationLevel", validation_level_to_string(*_level))); } if (_action) { doc.append(kvp("validationAction", validation_action_to_string(*_action))); } return doc.extract(); }
bsoncxx::document::value validation_criteria::to_document() const { auto doc = bsoncxx::builder::stream::document{}; if (_rule) { doc << "validator" << bsoncxx::types::b_document{*_rule}; } if (_level) { doc << "validationLevel" << validation_level_to_string(*_level); } if (_action) { doc << "validationAction" << validation_action_to_string(*_action); } return doc.extract(); }