userver
C++ Async Framework
Loading...
Searching...
No Matches
validators_pattern.hpp
1
#
pragma
once
2
3
#
include
<
stdexcept
>
4
#
include
<
string
>
5
6
#
include
<
userver
/
utils
/
regex
.
hpp
>
7
8
USERVER_NAMESPACE_BEGIN
9
10
namespace
chaotic {
11
12
template
<
const
std::string_view& Regex>
13
struct
Pattern final {
14
static
const
utils::regex kRegex;
15
16
static
void
Validate(
const
std::string& value) {
17
if
(!utils::regex_search(value, kRegex))
18
throw
std::runtime_error(
"doesn't match regex"
);
19
}
20
};
21
22
template
<
const
std::string_view& Regex>
23
inline
const
utils::regex Pattern<Regex>::kRegex{std::string{Regex}};
24
25
}
// namespace chaotic
26
27
USERVER_NAMESPACE_END
userver
chaotic
validators_pattern.hpp
Generated on Thu Sep 5 2024 11:15:44 for userver by
Doxygen
1.10.0