Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
rpc::validation::CustomValidator Class Referencefinal

A meta-validator that allows to specify a custom validation function. More...

#include <Validators.hpp>

Public Member Functions

template<typename Fn >
requires std::invocable<Fn, boost::json::value const&, std::string_view>
 CustomValidator (Fn &&fn)
 Constructs a custom validator from any supported callable.
 
MaybeError verify (boost::json::value const &value, std::string_view key) const
 Verify that the JSON value is valid according to the custom validation function stored.
 

Detailed Description

A meta-validator that allows to specify a custom validation function.

Constructor & Destructor Documentation

◆ CustomValidator()

template<typename Fn >
requires std::invocable<Fn, boost::json::value const&, std::string_view>
rpc::validation::CustomValidator::CustomValidator ( Fn && fn)
inlineexplicit

Constructs a custom validator from any supported callable.

Template Parameters
FnThe type of callable
Parameters
fnThe callable/function object

Member Function Documentation

◆ verify()

MaybeError rpc::validation::CustomValidator::verify ( boost::json::value const & value,
std::string_view key ) const
nodiscard

Verify that the JSON value is valid according to the custom validation function stored.

Parameters
valueThe JSON value representing the outer object
keyThe key used to retrieve the tested value from the outer object
Returns
Any compatible user-provided error if validation failed; otherwise no error is returned

The documentation for this class was generated from the following files: