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))
throw
std::runtime_error(
"doesn't match regex"
);
18
}
19
};
20
21
template
<
const
std::string_view& Regex>
22
inline
const
utils
::regex Pattern<Regex>::kRegex{std::string{Regex}};
23
24
}
// namespace chaotic
25
26
USERVER_NAMESPACE_END
userver
chaotic
validators_pattern.hpp
Generated on Tue Nov 19 2024 11:26:12 for userver by
Doxygen
1.10.0