Replies: 1 comment 5 replies
-
You can just write your own validator: class positive_double_validator
{
public:
using option_value_type = double;
positive_double_validator() = default;
positive_double_validator(positive_double_validator const &) = default;
positive_double_validator & operator=(positive_double_validator const &) = default;
positive_double_validator(positive_double_validator &&) = default;
positive_double_validator & operator=(positive_double_validator &&) = default;
~positive_double_validator() = default;
void operator()(option_value_type const & val) const
{
if (val < 0.0)
throw sharg::validation_error{"The value must be a positive double."};
}
std::string get_help_page_message() const
{
return "Value must be a positive double.";
}
}; |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, if I have an option where I would like to accept any positive non-zero double value, I use
However, in the help page it shows up like so:
This is pretty unsightly... Is there a way the readability can be improved somehow?
Beta Was this translation helpful? Give feedback.
All reactions