Mapper which validates the fields of a described type ( anch::Mapping ).
More...
#include <validation.hpp>
Public Member Functions | |
| ValidationMapper () | |
| void | validate (const T &value, anch::val::ValidationContext &context) const |
| template<typename P, typename... C> | |
| ValidationMapper< T > & | registerField (const std::string &name, P T::*member, C &&... constraints) |
| template<typename P, typename... C> | |
| ValidationMapper< T > & | registerField (const std::string &name, std::function< P(const T &)> getter, C &&... constraints) |
| template<typename P, typename... C> | |
| ValidationMapper< T > & | registerField (const std::string &name, std::function< void(T &, const P &)> setter, C &&... constraints) |
| template<typename P, typename... C> | |
| ValidationMapper< T > & | registerField (const std::string &name, std::function< P(const T &)> getter, std::function< void(T &, const P &)> setter, C &&... constraints) |
Static Public Member Functions | |
| static const ValidationMapper< T > & | instance () |
Mapper which validates the fields of a described type ( anch::Mapping ).
It satisfies the anch::ObjectMapper concept: the description registers its fields and their constraints. Fields with a value (member pointer or getter) are validated: their value constraints and their nested values (described objects, std::optional and pointers values, collections items, maps values). Fields registered with a setter only are not checked, and anch::val::required is not checked (an object always has its fields).
| T | the described type |
| anch::val::ValidationMapper< T >::ValidationMapper | ( | ) |
ValidationMapper constructor: fields are registered by anch::Mapping<T>
|
static |
Get the mapper of T (built on first use)
| ValidationMapper< T > & anch::val::ValidationMapper< T >::registerField | ( | const std::string & | name, |
| P T::* | member, | ||
| C &&... | constraints ) |
Register field with its member
| name | the field name |
| member | the member |
| constraints | the constraints |
this | ValidationMapper< T > & anch::val::ValidationMapper< T >::registerField | ( | const std::string & | name, |
| std::function< P(const T &)> | getter, | ||
| C &&... | constraints ) |
Register field with its getter
| name | the field name |
| getter | the getter |
| constraints | the constraints |
this | ValidationMapper< T > & anch::val::ValidationMapper< T >::registerField | ( | const std::string & | name, |
| std::function< P(const T &)> | getter, | ||
| std::function< void(T &, const P &)> | setter, | ||
| C &&... | constraints ) |
Register field with its getter and its setter: the getter value is validated
| name | the field name |
| getter | the getter |
| setter | the setter |
| constraints | the constraints |
this | ValidationMapper< T > & anch::val::ValidationMapper< T >::registerField | ( | const std::string & | name, |
| std::function< void(T &, const P &)> | setter, | ||
| C &&... | constraints ) |
Register field with its setter: it is not validated (no value)
| name | the field name |
| setter | the setter |
| constraints | the constraints |
this | void anch::val::ValidationMapper< T >::validate | ( | const T & | value, |
| anch::val::ValidationContext & | context ) const |
Validate object fields
| value | the object |
| context | the validation context |