diff options
Diffstat (limited to 'src/checker/errors/mail')
-rw-r--r-- | src/checker/errors/mail/at_sign.cpp | 18 | ||||
-rw-r--r-- | src/checker/errors/mail/at_sign.hpp | 16 | ||||
-rw-r--r-- | src/checker/errors/mail/empty.cpp | 8 | ||||
-rw-r--r-- | src/checker/errors/mail/empty.hpp | 2 |
4 files changed, 42 insertions, 2 deletions
diff --git a/src/checker/errors/mail/at_sign.cpp b/src/checker/errors/mail/at_sign.cpp new file mode 100644 index 0000000..f9dde08 --- /dev/null +++ b/src/checker/errors/mail/at_sign.cpp @@ -0,0 +1,18 @@ +#include <regex> + +#include "at_sign.hpp" +#include "logger/logger_set.hpp" + +namespace smtp::checker::errors::settings +{ + bool AtSign::Check( std::string const& line ) const + { + std::string mask = R"([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4}))"; + auto result = std::regex_search( line, std::regex{mask} ); + if(!result) + { + logger::LoggerSet::GetInstance()->LogError( GetMethodName(), "Error in mail note" ); + } + return result; + } +} diff --git a/src/checker/errors/mail/at_sign.hpp b/src/checker/errors/mail/at_sign.hpp new file mode 100644 index 0000000..2f72871 --- /dev/null +++ b/src/checker/errors/mail/at_sign.hpp @@ -0,0 +1,16 @@ +#pragma once + +#include "checker/errors/types/imails_error.hpp" + +namespace smtp::checker::errors::settings +{ + class AtSign : public types::IErrorMails + { + public: + AtSign() = default; + ~AtSign() override = default; + + bool Check( std::string const& line ) const override; + }; +} + diff --git a/src/checker/errors/mail/empty.cpp b/src/checker/errors/mail/empty.cpp index a893fbb..1c39e78 100644 --- a/src/checker/errors/mail/empty.cpp +++ b/src/checker/errors/mail/empty.cpp @@ -1,9 +1,15 @@ #include "empty.hpp" +#include "logger/logger_set.hpp" namespace smtp::checker::errors::settings { bool Empty::Check( std::string const& line ) const { - return !line.empty() && line != " "; + auto result = !line.empty() && line != " "; + if(!result) + { + logger::LoggerSet::GetInstance()->LogError( GetMethodName(), "Mails are empty" ); + } + return result; } } diff --git a/src/checker/errors/mail/empty.hpp b/src/checker/errors/mail/empty.hpp index 9e8c0da..945650e 100644 --- a/src/checker/errors/mail/empty.hpp +++ b/src/checker/errors/mail/empty.hpp @@ -4,7 +4,7 @@ namespace smtp::checker::errors::settings { - class Empty : public types::IError + class Empty : public types::IErrorMails { public: Empty() = default; |