Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
rpc::meta::WithCustomError< RequirementOrModifierType > Class Template Referencefinal

A meta-processor that wraps a validator and produces a custom error in case the wrapped validator fails. More...

#include <MetaProcessors.hpp>

Public Member Functions

 WithCustomError (RequirementOrModifierType reqOrModifier, Status err)
 Constructs a validator that calls the given validator req and returns a custom error err in case req fails.
 
MaybeError verify (boost::json::value const &value, std::string_view key) const
 Runs the stored validator and produces a custom error if the wrapped validator fails.
 
MaybeError verify (boost::json::value &value, std::string_view key) const
 Runs the stored validator and produces a custom error if the wrapped validator fails. This is an overload for the requirement which can modify the value. Such as IfType.
 
MaybeError modify (boost::json::value &value, std::string_view key) const
 Runs the stored modifier and produces a custom error if the wrapped modifier fails.
 

Detailed Description

template<typename RequirementOrModifierType>
requires SomeRequirement<RequirementOrModifierType> or SomeModifier<RequirementOrModifierType>
class rpc::meta::WithCustomError< RequirementOrModifierType >

A meta-processor that wraps a validator and produces a custom error in case the wrapped validator fails.

Constructor & Destructor Documentation

◆ WithCustomError()

template<typename RequirementOrModifierType >
rpc::meta::WithCustomError< RequirementOrModifierType >::WithCustomError ( RequirementOrModifierType reqOrModifier,
Status err )
inline

Constructs a validator that calls the given validator req and returns a custom error err in case req fails.

Parameters
reqOrModifierThe requirement to validate against
errThe custom error to return in case req fails

Member Function Documentation

◆ modify()

template<typename RequirementOrModifierType >
MaybeError rpc::meta::WithCustomError< RequirementOrModifierType >::modify ( boost::json::value & value,
std::string_view key ) const
inline

Runs the stored modifier and produces a custom error if the wrapped modifier fails.

Parameters
valueThe JSON value representing the outer object. This value can be modified by the modifier.
keyThe key used to retrieve the element from the outer object
Returns
Possibly an error

◆ verify() [1/2]

template<typename RequirementOrModifierType >
MaybeError rpc::meta::WithCustomError< RequirementOrModifierType >::verify ( boost::json::value & value,
std::string_view key ) const
inlinenodiscard

Runs the stored validator and produces a custom error if the wrapped validator fails. This is an overload for the requirement which can modify the value. Such as IfType.

Parameters
valueThe JSON value representing the outer object, this value can be modified by the requirement inside
keyThe key used to retrieve the element from the outer object
Returns
Possibly an error

◆ verify() [2/2]

template<typename RequirementOrModifierType >
MaybeError rpc::meta::WithCustomError< RequirementOrModifierType >::verify ( boost::json::value const & value,
std::string_view key ) const
inlinenodiscard

Runs the stored validator and produces a custom error if the wrapped validator fails.

Parameters
valueThe JSON value representing the outer object
keyThe key used to retrieve the element from the outer object
Returns
Possibly an error

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