diff --git a/README.md b/README.md index 6ad2d1168..6435018a8 100644 --- a/README.md +++ b/README.md @@ -491,11 +491,13 @@ Before parsing, you can set the following options: - `->default_str(string)`: Set the default string directly (NO VALIDATION OR CALLBACKS). This string will also be used as a default value if no arguments are passed and the value is requested. -- `->default_val(value)`: Generate the default string from a value and validate - that the value is also valid. For options that assign directly to a value type - the value in that type is also updated. Value must be convertible to a - string(one of known types or have a stream operator). The callback may be - triggered if the `run_callback_for_default` is set. +- `->default_val(value)`: Generate the default string from a value. The value is + converted (and any transforms are applied), but `check`s are not run against a + default, so a default that fails a check does not throw at configuration time; + checks apply to values parsed from the command line. For options that assign + directly to a value type the value in that type is also updated. Value must be + convertible to a string(one of known types or have a stream operator). The + callback may be triggered if the `run_callback_for_default` is set. - `->run_callback_for_default()`: This will force the option callback to be executed or the variable set when the `default_val` is set. - `->option_text(string)`: Sets the text between the option name and diff --git a/book/chapters/options.md b/book/chapters/options.md index b953e9f30..abac9e39a 100644 --- a/book/chapters/options.md +++ b/book/chapters/options.md @@ -233,7 +233,7 @@ that to add option modifiers. A full listing of the option modifiers: | `->each(void(std::string))` | Run a function on each parsed value, _in order_. | | `->default_str(string)` | set a default string for use in the help and as a default value if no arguments are passed and a value is requested | | `->default_function(std::string())` | Advanced: Change the function that `capture_default_str()` uses. | -| `->default_val(value)` | Generate the default string from a value and validate that the value is also valid. For options that assign directly to a value type the value in that type is also updated. Value must be convertible to a string(one of known types or have a stream operator). | +| `->default_val(value)` | Generate the default string from a value. The value is converted and any transforms are applied, but `check`s are not run against a default, so a default that fails a check does not throw at configuration time (checks apply to parsed input). For options that assign directly to a value type the value in that type is also updated. Value must be convertible to a string(one of known types or have a stream operator). | | `->capture_default_str()` | Store the current value attached and display it in the help string. | | `->always_capture_default()` | Always run `capture_default_str()` when creating new options. Only useful on an App's `option_defaults`. | | `->run_callback_for_default()` | Force the option callback to be executed or the variable set when the `default_val` is used. | diff --git a/include/CLI/Option.hpp b/include/CLI/Option.hpp index 3e89b32b3..f13d54071 100644 --- a/include/CLI/Option.hpp +++ b/include/CLI/Option.hpp @@ -671,8 +671,9 @@ class Option : public OptionBase