MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / validate_profile

Function validate_profile

atomic-canonical/src/provenance_export.rs:137–155  ·  view source on GitHub ↗
(payload: &ExportPayload)

Source from the content-addressed store, hash-verified

135}
136
137fn validate_profile(payload: &ExportPayload) -> Result<(), ExportError> {
138 if payload.schema != SCHEMA || payload.coverage != COVERAGE {
139 return Err(ExportError::Profile("unsupported schema or coverage"));
140 }
141 if payload.projections.is_empty() {
142 return Err(ExportError::Profile("no projections"));
143 }
144 for projection in &payload.projections {
145 if !projection
146 .get("@id")
147 .and_then(Value::as_str)
148 .is_some_and(|id| id.starts_with("urn:atomic:provgraph:"))
149 || !projection.get("@graph").is_some_and(Value::is_array)
150 {
151 return Err(ExportError::Profile("not an Atomic PROV projection"));
152 }
153 }
154 Ok(())
155}
156
157#[cfg(test)]
158mod tests {

Callers 2

sign_provenance_exportFunction · 0.85
verify_provenance_exportFunction · 0.85

Calls 3

getMethod · 0.65
ProfileEnum · 0.50
is_emptyMethod · 0.45

Tested by

no test coverage detected