Quandary
Loading...
Searching...
No Matches
Public Member Functions | List of all members
validators::VectorValidator< T > Class Template Reference

Chainable validator for vector TOML fields. More...

#include <config_validators.hpp>

Public Member Functions

 VectorValidator (const toml::table &config_, const std::string &key_)
 
VectorValidatorminLength (size_t min_len_)
 Requires minimum vector length.
 
VectorValidatorpositive ()
 Requires all vector elements to be strictly positive (> 0).
 
VectorValidatorhasLength (size_t exact_len_)
 Requires vector to have exactly the specified length.
 
std::vector< T > value ()
 Extracts and validates the vector field.
 
std::vector< T > valueOr (const std::vector< T > &default_value_)
 Extracts vector or returns default if missing.
 

Detailed Description

template<typename T>
class validators::VectorValidator< T >

Chainable validator for vector TOML fields.

This class provides type-safe extraction and validation of array fields from TOML configuration using the method chaining pattern described above.

Available Validation Methods

Extraction Methods

Type Requirements

The element type T must be a type supported by the TOML library (int, double, string, bool). For numeric types, you can use the positive() validation. For other types, only array-level validations (length) are available.

Template Parameters
TElement type of the vector (int, double, string, bool, etc.)

Constructor & Destructor Documentation

◆ VectorValidator()

template<typename T >
validators::VectorValidator< T >::VectorValidator ( const toml::table &  config_,
const std::string &  key_ 
)
inline

Member Function Documentation

◆ hasLength()

template<typename T >
VectorValidator & validators::VectorValidator< T >::hasLength ( size_t  exact_len_)
inline

Requires vector to have exactly the specified length.

Parameters
exact_len_Exact number of elements required
Returns
Reference to this validator for chaining

◆ minLength()

template<typename T >
VectorValidator & validators::VectorValidator< T >::minLength ( size_t  min_len_)
inline

Requires minimum vector length.

Parameters
min_len_Minimum number of elements (inclusive)
Returns
Reference to this validator for chaining

◆ positive()

template<typename T >
VectorValidator & validators::VectorValidator< T >::positive ( )
inline

Requires all vector elements to be strictly positive (> 0).

Returns
Reference to this validator for chaining

◆ value()

template<typename T >
std::vector< T > validators::VectorValidator< T >::value ( )
inline

Extracts and validates the vector field.

Returns
The validated vector
Exceptions
ValidationErrorIf validation fails

◆ valueOr()

template<typename T >
std::vector< T > validators::VectorValidator< T >::valueOr ( const std::vector< T > &  default_value_)
inline

Extracts vector or returns default if missing.

Parameters
default_value_Default vector to use if field is missing
Returns
The field vector or default
Exceptions
ValidationErrorIf field exists but validation fails

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