|
Quandary
|
Chainable validator for vector TOML fields. More...
#include <config_validators.hpp>
Public Member Functions | |
| VectorValidator (const toml::table &config_, const std::string &key_) | |
| VectorValidator & | minLength (size_t min_len_) |
| Requires minimum vector length. | |
| VectorValidator & | positive () |
| Requires all vector elements to be strictly positive (> 0). | |
| VectorValidator & | hasLength (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. | |
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.
minLength(size): Vector must have at least size elementshasLength(size): Vector must have exactly size elementspositive(): All elements must be > 0 (only for numeric types)value(): Extract validated array (throws if field missing or invalid)valueOr(default): Extract array or return default if field missingThe 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.
| T | Element type of the vector (int, double, string, bool, etc.) |
|
inline |
|
inline |
Requires vector to have exactly the specified length.
| exact_len_ | Exact number of elements required |
|
inline |
Requires minimum vector length.
| min_len_ | Minimum number of elements (inclusive) |
|
inline |
Requires all vector elements to be strictly positive (> 0).
|
inline |
Extracts and validates the vector field.
| ValidationError | If validation fails |
|
inline |
Extracts vector or returns default if missing.
| default_value_ | Default vector to use if field is missing |
| ValidationError | If field exists but validation fails |