diff --git a/include/micm/configure/solver_config.hpp b/include/micm/configure/solver_config.hpp index 9c12a3364..0ba77906b 100644 --- a/include/micm/configure/solver_config.hpp +++ b/include/micm/configure/solver_config.hpp @@ -334,14 +334,12 @@ namespace micm // required keys const std::string NAME = "name"; - std::array required_keys = { NAME }; - - // Check if it contains the required key(s) - for (const auto& key : required_keys) + auto status = ValidateSchema(object, { NAME, "type" }, { "tracer type", "absolute tolerance", "diffusion coefficient [m2 s-1]", "molecular weight [kg mol-1]" }); + if (status != ConfigParseStatus::Success) { - if (!ValidateJsonWithKey(object, key)) - return ConfigParseStatus::RequiredKeyNotFound; + return status; } + std::string name = object[NAME].get(); // Load remaining keys as properties @@ -363,12 +361,12 @@ namespace micm ConfigParseStatus ParseMechanism(const json& object) { - std::vector required_keys = { "name", "reactions" }; - for (const auto& key : required_keys) + auto status = ValidateSchema(object, { "name", "reactions", "type" }, {}); + if (status != ConfigParseStatus::Success) { - if (!ValidateJsonWithKey(object, key)) - return ConfigParseStatus::RequiredKeyNotFound; + return status; } + std::vector objects; for (const auto& element : object["reactions"]) {