MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / validate

Method validate

lib/config/config.cc:221–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221std::vector<std::string> Config::validate()
222{
223 std::vector<std::string> results;
224
225 /* Ensure that only one item in each group is set. */
226
227 std::map<const OptionGroupProto*, const OptionProto*> optionsByGroup;
228 for (auto& [group, option, hasArgument] : _appliedOptions)
229 if (group)
230 {
231 auto& o = optionsByGroup[group];
232 if (o)
233 results.push_back(
234 fmt::format("multiple mutually exclusive values set for "
235 "group '{}': valid values are: {}",
236 group->comment(),
237 getValidValues(*group)));
238 o = option;
239 }
240
241 /* Ensure that every group has an option set. */
242
243 for (const auto& group : base()->option_group())
244 {
245 if (!optionsByGroup.contains(&group))
246 {
247 results.push_back(
248 fmt::format("no value set for group '{}': valid values are: {}",
249 group.comment(),
250 getValidValues(group)));
251 }
252 }
253
254 /* Check option requirements. */
255
256 for (auto [group, option, hasArgument] : _appliedOptions)
257 {
258 try
259 {
260 checkOptionValid(*option);
261 }
262 catch (const InapplicableOptionException& e)
263 {
264 results.push_back(e.message);
265 }
266 }
267
268 return results;
269}
270
271void Config::validateAndThrow()
272{

Callers

nothing calls this directly

Calls 3

getValidValuesFunction · 0.85
push_backMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected