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

Method validate

atomic-agent/src/event.rs:629–645  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

627 }
628
629 pub fn validate(&self) -> Result<(), ProvenanceJournalError> {
630 if self.schema_version != PROVENANCE_JOURNAL_VERSION {
631 return Err(ProvenanceJournalError::UnsupportedVersion(
632 self.schema_version,
633 ));
634 }
635 if self.event_id.trim().is_empty() {
636 return Err(ProvenanceJournalError::EmptyEventId);
637 }
638 if self.session_id.trim().is_empty() {
639 return Err(ProvenanceJournalError::EmptySessionId);
640 }
641 if self.generation == 0 {
642 return Err(ProvenanceJournalError::InvalidGeneration);
643 }
644 Ok(())
645 }
646
647 pub fn to_json_bytes(&self) -> Result<Vec<u8>, ProvenanceJournalError> {
648 self.validate()?;

Callers 3

to_json_bytesMethod · 0.45
from_json_bytesMethod · 0.45

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected