Rename function for clarity

pull/1186/head
Stephen Shelton 4 years ago
parent 8160c13458
commit 60d0bf2a9b
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -45,7 +45,7 @@ Configuration::addConfigValue(string_view section, string_view name, string_view
} }
void void
Configuration::validate() Configuration::validateRequiredFields()
{ {
visitSections([&](const std::string& section, const DefinitionMap&) { visitSections([&](const std::string& section, const DefinitionMap&) {
visitDefinitions(section, [&](const std::string&, const ConfigDefinition_ptr& def) { visitDefinitions(section, [&](const std::string&, const ConfigDefinition_ptr& def) {

@ -222,16 +222,11 @@ namespace llarp
return derived->getValue(); return derived->getValue();
} }
/// Validate the config, presumably called after parsing. This will throw an exception if the /// Validate that all required fields are present.
/// parsed values do not meet the provided definition.
///
/// Note that this will only handle a subset of errors that may occur. Specifically, this will
/// handle errors about missing required fields, whereas errors about incorrect type,
/// duplicates, etc. are handled during parsing.
/// ///
/// @throws std::invalid_argument if configuration constraints are not met /// @throws std::invalid_argument if configuration constraints are not met
void void
validate(); validateRequiredFields();
/// Generate a config string from the current config definition, optionally using overridden /// Generate a config string from the current config definition, optionally using overridden
/// values. The generated config will preserve insertion order of both sections and their /// values. The generated config will preserve insertion order of both sections and their

@ -105,11 +105,11 @@ TEST_CASE("Configuration required test", "[config]")
false, false,
1)); 1));
CHECK_THROWS(config.validate()); CHECK_THROWS(config.validateRequiredFields());
config.addConfigValue("router", "threads", "12"); config.addConfigValue("router", "threads", "12");
CHECK_NOTHROW(config.validate()); CHECK_NOTHROW(config.validateRequiredFields());
} }
TEST_CASE("Configuration section test", "[config]") TEST_CASE("Configuration section test", "[config]")
@ -128,13 +128,13 @@ TEST_CASE("Configuration section test", "[config]")
false, false,
1)); 1));
CHECK_THROWS(config.validate()); CHECK_THROWS(config.validateRequiredFields());
config.addConfigValue("foo", "bar", "5"); config.addConfigValue("foo", "bar", "5");
CHECK_THROWS(config.validate()); CHECK_THROWS(config.validateRequiredFields());
CHECK_NOTHROW(config.addConfigValue("goo", "bar", "6")); CHECK_NOTHROW(config.addConfigValue("goo", "bar", "6"));
CHECK_NOTHROW(config.validate()); CHECK_NOTHROW(config.validateRequiredFields());
CHECK(config.getConfigValue<int>("foo", "bar") == 5); CHECK(config.getConfigValue<int>("foo", "bar") == 5);
CHECK(config.getConfigValue<int>("goo", "bar") == 6); CHECK(config.getConfigValue<int>("goo", "bar") == 6);

Loading…
Cancel
Save