4#include "rpc/common/ValidationHelpers.hpp"
6#include <boost/json/value.hpp>
7#include <boost/json/value_to.hpp>
28 : warningCode(code), extraMessage(std::move(message))
36 std::string extraMessage;
38using Warnings = std::vector<Warning>;
43template <
typename... T>
59 [[nodiscard]]
static std::optional<Warning>
60 check(boost::json::value
const& value, std::string_view key)
62 if (value.is_object() and value.as_object().contains(key)) {
64 WarningCode::WarnRpcDeprecated, fmt::format(
"Field '{}' is deprecated.", key)
96 [[nodiscard]] std::optional<Warning>
97 check(boost::json::value
const& value, std::string_view key)
const
99 if (value.is_object() and value.as_object().contains(key) and
100 validation::checkType<T>(value.as_object().at(key))) {
101 using boost::json::value_to;
102 auto const res = value_to<T>(value.as_object().at(key));
105 WarningCode::WarnRpcDeprecated,
106 fmt::format(
"Value '{}' for field '{}' is deprecated", value_, key)
117template <
typename... T>
118Deprecated(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:97
Deprecated(T val)
Construct a new Deprecated object.
Definition Checkers.hpp:85
static std::optional< Warning > check(boost::json::value const &value, std::string_view key)
Check if a field is deprecated.
Definition Checkers.hpp:60
Check for a deprecated fields.
Definition Checkers.hpp:44
WarningCode
Warning codes that can be returned by clio.
Definition Errors.hpp:181
bool operator==(MaybeError const &lhs, MaybeError const &rhs)
Check if two MaybeError objects are equal.
Definition Types.hpp:46
Warning that checks can return.
Definition Checkers.hpp:20
Warning(WarningCode code, std::string message)
Construct a new Warning object.
Definition Checkers.hpp:27