diff --git a/llarp/config/definition.cpp b/llarp/config/definition.cpp index c09b6c7e5..13035a3fd 100644 --- a/llarp/config/definition.cpp +++ b/llarp/config/definition.cpp @@ -45,7 +45,7 @@ Configuration::addConfigValue(string_view section, string_view name, string_view } void -Configuration::validate() +Configuration::validateRequiredFields() { visitSections([&](const std::string& section, const DefinitionMap&) { visitDefinitions(section, [&](const std::string&, const ConfigDefinition_ptr& def) { diff --git a/llarp/config/definition.hpp b/llarp/config/definition.hpp index 64e83925d..2cd7f7ce0 100644 --- a/llarp/config/definition.hpp +++ b/llarp/config/definition.hpp @@ -222,16 +222,11 @@ namespace llarp return derived->getValue(); } - /// Validate the config, presumably called after parsing. This will throw an exception if the - /// 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. + /// Validate that all required fields are present. /// /// @throws std::invalid_argument if configuration constraints are not met void - validate(); + validateRequiredFields(); /// 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 diff --git a/test/config/test_llarp_config_definition.cpp b/test/config/test_llarp_config_definition.cpp index 13e8bf607..768994dba 100644 --- a/test/config/test_llarp_config_definition.cpp +++ b/test/config/test_llarp_config_definition.cpp @@ -105,11 +105,11 @@ TEST_CASE("Configuration required test", "[config]") false, 1)); - CHECK_THROWS(config.validate()); + CHECK_THROWS(config.validateRequiredFields()); config.addConfigValue("router", "threads", "12"); - CHECK_NOTHROW(config.validate()); + CHECK_NOTHROW(config.validateRequiredFields()); } TEST_CASE("Configuration section test", "[config]") @@ -128,13 +128,13 @@ TEST_CASE("Configuration section test", "[config]") false, 1)); - CHECK_THROWS(config.validate()); + CHECK_THROWS(config.validateRequiredFields()); config.addConfigValue("foo", "bar", "5"); - CHECK_THROWS(config.validate()); + CHECK_THROWS(config.validateRequiredFields()); CHECK_NOTHROW(config.addConfigValue("goo", "bar", "6")); - CHECK_NOTHROW(config.validate()); + CHECK_NOTHROW(config.validateRequiredFields()); CHECK(config.getConfigValue("foo", "bar") == 5); CHECK(config.getConfigValue("goo", "bar") == 6);