summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bsontypes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/bson/bsontypes.cpp')
-rw-r--r--src/mongo/bson/bsontypes.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/bson/bsontypes.cpp b/src/mongo/bson/bsontypes.cpp
index 59fb2abba96..8be3c5e1d04 100644
--- a/src/mongo/bson/bsontypes.cpp
+++ b/src/mongo/bson/bsontypes.cpp
@@ -137,6 +137,16 @@ BSONType typeFromName(StringData name) {
return *typeAlias;
}
+Status isValidBSONTypeName(StringData typeName) {
+ try {
+ typeFromName(typeName);
+ } catch (const ExceptionFor<ErrorCodes::BadValue>& ex) {
+ return ex.toStatus();
+ }
+
+ return Status::OK();
+}
+
std::ostream& operator<<(std::ostream& stream, BSONType type) {
return stream << typeName(type);
}