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

#include <form.hpp>

Public Member Functions

 FormField (std::string field_path, T initial=T{})
 Construct from (field_path, initial).
const std::string & field_path () const noexcept
FormFieldrule (typename Validator< T >::Rule r, std::string rule_id_value={})
template<std::predicate< const T & > P>
FormFieldmust (P &&predicate, std::string message, std::string rule_id_value={})
FormFieldrequired (std::string message="required")
FormFieldmin_length (std::size_t n, std::string message)
void reset (T v=T{})

Public Attributes

Property< T > value
Validator< T > validator
Property< bool > is_valid {true}
Property< std::string > error {""}
 First-error message string for trivial UI binding.
Property< std::optional<::aria::Error > > error_full {std::nullopt}
 Full first-error record.
Property< bool > touched {false}
Property< bool > dirty {false}

Constructor & Destructor Documentation

◆ FormField()

template<PropertyValue T>
aria::binding::FormField< T >::FormField ( std::string field_path,
T initial = T{} )
inlineexplicit

Construct from (field_path, initial).

The path flows into the owned Validator so every emitted Error is keyed by it.

Member Function Documentation

◆ field_path()

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

◆ rule()

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

◆ must()

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

◆ required()

template<PropertyValue T>
FormField & aria::binding::FormField< T >::required ( std::string message = "required")
inline

◆ min_length()

template<PropertyValue T>
FormField & aria::binding::FormField< T >::min_length ( std::size_t n,
std::string message )
inline

◆ reset()

template<PropertyValue T>
void aria::binding::FormField< T >::reset ( T v = T{})
inline

Member Data Documentation

◆ value

template<PropertyValue T>
Property<T> aria::binding::FormField< T >::value

◆ validator

template<PropertyValue T>
Validator<T> aria::binding::FormField< T >::validator

◆ is_valid

template<PropertyValue T>
Property<bool> aria::binding::FormField< T >::is_valid {true}

◆ error

template<PropertyValue T>
Property<std::string> aria::binding::FormField< T >::error {""}

First-error message string for trivial UI binding.

For full provenance use error_full or validator.state().

◆ error_full

template<PropertyValue T>
Property<std::optional<::aria::Error> > aria::binding::FormField< T >::error_full {std::nullopt}

Full first-error record.

Carries the same message as error when present, plus kind / key / severity.

◆ touched

template<PropertyValue T>
Property<bool> aria::binding::FormField< T >::touched {false}

◆ dirty

template<PropertyValue T>
Property<bool> aria::binding::FormField< T >::dirty {false}

The documentation for this class was generated from the following file:
  • modules/binding/include/aria/binding/form.hpp