23#include "rpc/common/ValidationHelpers.hpp"
25#include <boost/json/value.hpp>
26#include <boost/json/value_to.hpp>
46 Warning(
WarningCode code, std::string message) : warningCode(code), extraMessage(std::move(message))
51 operator==(
Warning const& other)
const =
default;
54 std::string extraMessage;
56using Warnings = std::vector<Warning>;
61template <
typename... T>
77 [[nodiscard]]
static std::optional<Warning>
78 check(boost::json::value
const& value, std::string_view key)
80 if (value.is_object() and value.as_object().contains(key))
81 return Warning{WarningCode::WarnRpcDeprecated, fmt::format(
"Field '{}' is deprecated.", key)};
111 [[nodiscard]] std::optional<Warning>
112 check(boost::json::value
const& value, std::string_view key)
const
114 if (value.is_object() and value.as_object().contains(key) and
115 validation::checkType<T>(value.as_object().at(key))) {
116 using boost::json::value_to;
117 auto const res = value_to<T>(value.as_object().at(key));
120 WarningCode::WarnRpcDeprecated, fmt::format(
"Value '{}' for field '{}' is deprecated", value_, key)
131template <
typename... T>
132Deprecated(T&&...) -> Deprecated<T...>;
std::optional< Warning > check(boost::json::value const &value, std::string_view key) const
Check if a value of a field is deprecated.
Definition Checkers.hpp:112
Deprecated(T val)
Construct a new Deprecated object.
Definition Checkers.hpp:100
static std::optional< Warning > check(boost::json::value const &value, std::string_view key)
Check if a field is deprecated.
Definition Checkers.hpp:78
Check for a deprecated fields.
Definition Checkers.hpp:62
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:187
Warning that checks can return.
Definition Checkers.hpp:39
Warning(WarningCode code, std::string message)
Construct a new Warning object.
Definition Checkers.hpp:46