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

Method validate_string_value

crates/openshell-core/src/settings.rs:51–56  ·  view source on GitHub ↗

Validate a string value against [`allowed_string_values`]. Returns `Ok(())` when the setting has no constraint or when the value is in the allowed list. On rejection, returns the allowed slice so callers can format their own diagnostic. [`allowed_string_values`]: Self::allowed_string_values # Errors Returns the allowed-value slice when the setting has an `allowed_string_values` whitelist and `v

(&self, value: &str)

Source from the content-addressed store, hash-verified

49 /// Returns the allowed-value slice when the setting has an
50 /// `allowed_string_values` whitelist and `value` is not in it.
51 pub fn validate_string_value(&self, value: &str) -> Result<(), &'static [&'static str]> {
52 match self.allowed_string_values {
53 Some(allowed) if !allowed.contains(&value) => Err(allowed),
54 _ => Ok(()),
55 }
56 }
57}
58
59/// Static registry of currently-supported runtime settings.

Calls

no outgoing calls