MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / validate_matcher_map

Function validate_matcher_map

crates/openshell-supervisor-network/src/l7/mod.rs:562–579  ·  view source on GitHub ↗

Validate a matcher map when it exists. Null is treated like omission because policy loading normalizes absent optional maps the same way.

(
    errors: &mut Vec<String>,
    warnings: &mut Vec<String>,
    loc: &str,
    value: Option<&serde_json::Value>,
)

Source from the content-addressed store, hash-verified

560// Validate a matcher map when it exists. Null is treated like omission because
561// policy loading normalizes absent optional maps the same way.
562fn validate_matcher_map(
563 errors: &mut Vec<String>,
564 warnings: &mut Vec<String>,
565 loc: &str,
566 value: Option<&serde_json::Value>,
567) {
568 let Some(value) = value.filter(|v| !v.is_null()) else {
569 return;
570 };
571 let Some(obj) = value.as_object() else {
572 errors.push(format!("{loc}: expected map of matchers"));
573 return;
574 };
575
576 for (key, matcher) in obj {
577 validate_matcher_value(errors, warnings, &format!("{loc}.{key}"), matcher);
578 }
579}
580
581// Validate one matcher leaf. Objects must use the explicit matcher keys.
582fn validate_matcher_value(

Callers 1

validate_l7_policiesFunction · 0.85

Calls 2

validate_matcher_valueFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected