A validator that checks whether a value is inside a list of valid values. More...
#include <seqan3/argument_parser/validators.hpp>
Public Types | |
using | value_type = option_value_type |
Type of values that are tested by validator. | |
Public Member Functions | |
std::string | get_help_page_message () const |
Returns a message that can be appended to the (positional) options help page info. | |
void | operator() (value_type const &cmp) const |
Tests whether cmp lies inside values. More... | |
template<std::ranges::ForwardRange range_type> | |
void | operator() (range_type const &range) const |
Tests whether every element in range lies inside values. More... | |
value_list_validator (std::vector< value_type > v) | |
Constructing from a vector. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<Arithmetic option_value_type> | |
value_list_validator (std::vector< option_value_type >) -> value_list_validator< double > | |
Type deduction guides. | |
template<Arithmetic option_value_type> | |
value_list_validator (std::initializer_list< option_value_type >) -> value_list_validator< double > | |
value_list_validator (std::vector< const char * >) -> value_list_validator< std::string > | |
value_list_validator (std::initializer_list< const char * >) -> value_list_validator< std::string > | |
Requirements for seqan3::Validator | |
You can expect these (meta-)functions on all types that implement seqan3::Validator. | |
void | operator() (value_type const &cmp) const |
Validates the value 'cmp' and throws a seqan3::validation_failed on failure. More... | |
A validator that checks whether a value is inside a list of valid values.
On construction, the validator must receive a list (vector) of valid values. The struct than acts as a functor, that throws a seqan3::parser_invalid_argument exception whenever a given value is not in the given list.
|
inline |
Constructing from a vector.
[in] | v | The vector of valid values to test. |
|
inline |
Tests whether cmp lies inside values.
cmp | The input value to check. |
parser_invalid_argument |
|
inline |
Tests whether every element in range
lies inside values.
range_type | The type of range to check; must model std::ranges::ForwardRange. |
range | The input range to iterate over and check every element. |
parser_invalid_argument |
|
related |
Validates the value 'cmp' and throws a seqan3::validation_failed on failure.
value_type | The type of the value to be validated. |
[in,out] | cmp | The value to be validated. |
seqan3::validation_failed | if value 'cmp' does not pass validation. |