diff --git a/services/lib/src/GlobalTools.cpp b/services/lib/src/GlobalTools.cpp --- a/services/lib/src/GlobalTools.cpp +++ b/services/lib/src/GlobalTools.cpp @@ -1,5 +1,6 @@ #include "GlobalTools.h" +#include #include #include #include @@ -7,6 +8,7 @@ #include #include +#include #include namespace comm { @@ -43,6 +45,19 @@ return boost::uuids::to_string(random_generator()); } +bool validateUUID(const std::string &uuid) { + const std::regex uuidV4RegexFormat( + "^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$", + std::regex_constants::icase); + try { + return std::regex_match(uuid, uuidV4RegexFormat); + } catch (const std::exception &e) { + LOG(ERROR) << "Tools: " + << "Got an exception at `validateUUID`: " << e.what(); + return false; + } +} + } // namespace tools } // namespace network } // namespace comm