23#include "rpc/common/ValidationHelpers.hpp"
25#include <boost/json/value.hpp>
26#include <boost/json/value_to.hpp>
27#include <fmt/format.h>
47 : warningCode(code), extraMessage(std::move(message))
55 std::string extraMessage;
57using Warnings = std::vector<Warning>;
62template <
typename... T>
78 [[nodiscard]]
static std::optional<Warning>
79 check(boost::json::value
const& value, std::string_view key)
81 if (value.is_object() and value.as_object().contains(key))
83 WarningCode::WarnRpcDeprecated, fmt::format(
"Field '{}' is deprecated.", key)
114 [[nodiscard]] std::optional<Warning>
115 check(boost::json::value
const& value, std::string_view key)
const
117 if (value.is_object() and value.as_object().contains(key) and
118 validation::checkType<T>(value.as_object().at(key))) {
119 using boost::json::value_to;
120 auto const res = value_to<T>(value.as_object().at(key));
123 WarningCode::WarnRpcDeprecated,
124 fmt::format(
"Value '{}' for field '{}' is deprecated", value_, key)
135template <
typename... T>
136Deprecated(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:115
Deprecated(T val)
Construct a new Deprecated object.
Definition Checkers.hpp:103
static std::optional< Warning > check(boost::json::value const &value, std::string_view key)
Check if a field is deprecated.
Definition Checkers.hpp:79
Check for a deprecated fields.
Definition Checkers.hpp:63
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:200
bool operator==(MaybeError const &lhs, MaybeError const &rhs)
Check if two MaybeError objects are equal.
Definition Types.hpp:65
Warning that checks can return.
Definition Checkers.hpp:39
Warning(WarningCode code, std::string message)
Construct a new Warning object.
Definition Checkers.hpp:46