Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::Validator< T > Class Template Reference

#include <validator.hpp>

Public Types

using Rule = std::function<std::optional<std::string>(const T&)>
 User-supplied rule body: returns a message when the value fails, std::nullopt when it passes.

Public Member Functions

 Validator (Property< T > &source, std::string field_path={})
 ~Validator ()
const std::string & field_path () const noexcept
Validatorrule (Rule r, std::string rule_id_value={})
template<std::predicate< const T & > P>
Validatormust (P &&predicate, std::string message, std::string rule_id_value={})
Validatorwarning (Rule r, std::string rule_id_value={})
template<std::predicate< const T & > P>
Validatorshould (P &&predicate, std::string message, std::string rule_id_value={})
Validatorrules (std::initializer_list< Rule > rs)
void touch ()
void reset_touched ()
void reset_dirty ()
void begin_pending ()
void end_pending (std::vector< std::string > extra_messages)
 Settle the async validation: clears pending and stores extra_messages as additional Error-severity entries until the next sync run replaces them.
void end_pending (std::vector< Error > extra)
 Settle pending with caller-shaped error records.
void end_pending ()
 Settle pending without any extra errors.
void cancel_pending ()
 Cancel pending work while preserving the previous validation result, including async errors and warnings.
Property< ValidationState > & state () noexcept
const Property< ValidationState > & state () const noexcept
Property< ValidationResult > & result () noexcept
const Property< ValidationResult > & result () const noexcept

Friends

template<class U>
class async::AsyncValidator

Member Typedef Documentation

◆ Rule

template<PropertyValue T>
using aria::Validator< T >::Rule = std::function<std::optional<std::string>(const T&)>

User-supplied rule body: returns a message when the value fails, std::nullopt when it passes.

The framework wraps the returned message into an Error (kind = Validation) together with the owning Validator's field_path and either an explicit or auto-generated rule_id.

Constructor & Destructor Documentation

◆ Validator()

template<PropertyValue T>
aria::Validator< T >::Validator ( Property< T > & source,
std::string field_path = {} )
inlineexplicit

◆ ~Validator()

template<PropertyValue T>
aria::Validator< T >::~Validator ( )
inline

Member Function Documentation

◆ field_path()

template<PropertyValue T>
const std::string & aria::Validator< T >::field_path ( ) const
inlinenodiscardnoexcept

◆ rule()

template<PropertyValue T>
Validator & aria::Validator< T >::rule ( Rule r,
std::string rule_id_value = {} )
inline

◆ must()

template<PropertyValue T>
template<std::predicate< const T & > P>
Validator & aria::Validator< T >::must ( P && predicate,
std::string message,
std::string rule_id_value = {} )
inline

◆ warning()

template<PropertyValue T>
Validator & aria::Validator< T >::warning ( Rule r,
std::string rule_id_value = {} )
inline

◆ should()

template<PropertyValue T>
template<std::predicate< const T & > P>
Validator & aria::Validator< T >::should ( P && predicate,
std::string message,
std::string rule_id_value = {} )
inline

◆ rules()

template<PropertyValue T>
Validator & aria::Validator< T >::rules ( std::initializer_list< Rule > rs)
inline

◆ touch()

template<PropertyValue T>
void aria::Validator< T >::touch ( )
inline

◆ reset_touched()

template<PropertyValue T>
void aria::Validator< T >::reset_touched ( )
inline

◆ reset_dirty()

template<PropertyValue T>
void aria::Validator< T >::reset_dirty ( )
inline

◆ begin_pending()

template<PropertyValue T>
void aria::Validator< T >::begin_pending ( )
inline

◆ end_pending() [1/3]

template<PropertyValue T>
void aria::Validator< T >::end_pending ( std::vector< std::string > extra_messages)
inline

Settle the async validation: clears pending and stores extra_messages as additional Error-severity entries until the next sync run replaces them.

Each entry is keyed under this validator's field_path and an auto-generated async_<N> rule_id.

◆ end_pending() [2/3]

template<PropertyValue T>
void aria::Validator< T >::end_pending ( std::vector< Error > extra)
inline

Settle pending with caller-shaped error records.

Empty field_paths are backfilled with the validator's own.

◆ end_pending() [3/3]

template<PropertyValue T>
void aria::Validator< T >::end_pending ( )
inline

Settle pending without any extra errors.

◆ cancel_pending()

template<PropertyValue T>
void aria::Validator< T >::cancel_pending ( )
inline

Cancel pending work while preserving the previous validation result, including async errors and warnings.

Cancellation is not a new result.

◆ state() [1/2]

template<PropertyValue T>
Property< ValidationState > & aria::Validator< T >::state ( )
inlinenodiscardnoexcept

◆ state() [2/2]

template<PropertyValue T>
const Property< ValidationState > & aria::Validator< T >::state ( ) const
inlinenodiscardnoexcept

◆ result() [1/2]

template<PropertyValue T>
Property< ValidationResult > & aria::Validator< T >::result ( )
inlinenodiscardnoexcept

◆ result() [2/2]

template<PropertyValue T>
const Property< ValidationResult > & aria::Validator< T >::result ( ) const
inlinenodiscardnoexcept

◆ async::AsyncValidator

template<PropertyValue T>
template<class U>
friend class async::AsyncValidator
friend

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