7#include <userver/formats/common/meta.hpp>
8#include <userver/formats/parse/to.hpp>
9#include <userver/http/status_code.hpp>
11USERVER_NAMESPACE_BEGIN
15template <
typename Value,
16 typename = std::enable_if_t<formats::common::kIsFormatValue<Value>>>
18 using IntType = std::underlying_type_t<StatusCode>;
19 constexpr IntType kMinCode = 100;
20 constexpr IntType kMaxCode = 599;
22 const auto integer = value.
template As<IntType>();
23 if (integer < kMinCode || integer > kMaxCode) {
24 throw typename Value::Exception(
25 fmt::format(
"StatusCode value {} out of [{}..{}] range at '{}'",
26 integer, kMinCode, kMaxCode, value.GetPath()));
29 return StatusCode{integer};