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

Method validate

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

Source from the content-addressed store, hash-verified

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