22#include <boost/json/array.hpp>
23#include <boost/json/object.hpp>
24#include <boost/json/value.hpp>
29namespace rpc::validation {
38template <
typename Expected>
39[[nodiscard]]
bool static checkType(boost::json::value
const& value)
41 auto hasError =
false;
42 if constexpr (std::is_same_v<Expected, bool>) {
43 if (not value.is_bool())
45 }
else if constexpr (std::is_same_v<Expected, std::string>) {
46 if (not value.is_string())
48 }
else if constexpr (std::is_same_v<Expected, double> or std::is_same_v<Expected, float>) {
49 if (not value.is_double())
51 }
else if constexpr (std::is_same_v<Expected, boost::json::array>) {
52 if (not value.is_array())
54 }
else if constexpr (std::is_same_v<Expected, boost::json::object>) {
55 if (not value.is_object())
57 }
else if constexpr (std::is_convertible_v<Expected, uint64_t> or std::is_convertible_v<Expected, int64_t>) {
58 if (not value.is_int64() && not value.is_uint64())
61 if constexpr (std::is_unsigned_v<Expected>) {
62 if (value.is_int64() and value.as_int64() < 0)