MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / check

Function check

nodedb-array/src/schema/validation/attrs.rs:17–35  ·  view source on GitHub ↗
(array: &str, attrs: &[AttrSpec])

Source from the content-addressed store, hash-verified

15use crate::schema::attr_spec::AttrSpec;
16
17pub fn check(array: &str, attrs: &[AttrSpec]) -> ArrayResult<()> {
18 if attrs.is_empty() {
19 return Err(ArrayError::InvalidSchema {
20 array: array.to_string(),
21 detail: "at least one attribute is required".to_string(),
22 });
23 }
24 let mut seen = HashSet::with_capacity(attrs.len());
25 for a in attrs {
26 if !seen.insert(a.name.as_str()) {
27 return Err(ArrayError::InvalidAttr {
28 array: array.to_string(),
29 attr: a.name.clone(),
30 detail: "duplicate attribute name".to_string(),
31 });
32 }
33 }
34 Ok(())
35}
36
37#[cfg(test)]
38mod tests {

Callers

nothing calls this directly

Calls 6

to_stringMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45
insertMethod · 0.45
as_strMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected