|
| | Validator (const toml::table &config_, const std::string &key_) |
| |
| Validator & | greaterThan (T greater_than_) |
| | Requires value to be strictly greater than threshold.
|
| |
| Validator & | greaterThanEqual (T greater_than_equal_) |
| | Requires value to be greater than or equal to threshold.
|
| |
| Validator & | lessThan (T less_than_) |
| | Requires value to be strictly less than threshold.
|
| |
| Validator & | positive () |
| | Requires value to be strictly positive (> 0).
|
| |
| T | value () |
| | Extracts and validates the field value.
|
| |
| T | valueOr (T default_value_) |
| | Extracts field value or returns default if missing.
|
| |
template<typename T>
class validators::Validator< T >
Chainable validator for scalar TOML fields.
This class provides type-safe extraction and validation of single-value fields from TOML configuration using the method chaining pattern described above.
Available Validation Methods
If any of the following methods are called, the corresponding validation is applied when extracting the value, and an error is thrown if the validation fails.
greaterThan(value): Field must be > value
greaterThanEqual(value): Field must be >= value
lessThan(value): Field must be < value
positive(): Field must be > 0 (shorthand for greaterThan(0))
Extraction Methods
value(): Extract scalar or throws an error if field is missing or invalid
valueOr(default): Extract scalar or return default if field missing
- Template Parameters
-
| T | Type of field to validate (int, double, string, bool, etc.) |