diff --git a/include/valijson/validation_visitor.hpp b/include/valijson/validation_visitor.hpp index 3adb0d1..152d101 100644 --- a/include/valijson/validation_visitor.hpp +++ b/include/valijson/validation_visitor.hpp @@ -375,7 +375,7 @@ public: } } else if (format == "time") { // Matches times like: 16:52:45Z, 16:52:45+02:00 - std::regex time_regex("^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$"); + std::regex time_regex("^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$"); if (std::regex_match(s, time_regex)) { return true; } else { @@ -387,7 +387,7 @@ public: } } else if (format == "date-time") { // Matches data times like: 2022-07-18T16:52:45Z, 2022-07-18T16:52:45+02:00 - std::regex datetime_regex("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\.[0-9]+)?(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9]))$"); + std::regex datetime_regex("^([0-9]+)-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])[Tt]([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9]|60)(\\.[0-9]+)?(([Zz])|([\\+|\\-]([01][0-9]|2[0-3]):[0-5][0-9]))$"); std::smatch matches; if (std::regex_match(s, matches, datetime_regex)) { const auto month = std::stoi(matches[2].str());