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
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, if I have an option where I would like to accept any positive non-zero double value, I use
sharg::arithmetic_range_validator dbl_val{0.0, std::numeric_limits<double>::max()};However, in the help page it shows up like so:
-j, --reThreshold (double) SVs satisfy read-depth evidence >= {Q3 + (IQR * h)} get a vote. Default: 1. Value must be in range [0.000000,179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000].This is pretty unsightly... Is there a way the readability can be improved somehow?
Beta Was this translation helpful? Give feedback.
All reactions