AgentSessionManager.Persistence.EventValidator
(AgentSessionManager v0.8.0)
Copy Markdown
View Source
Validates event structure and data shapes.
Structural validation is strict — events that fail are rejected and not persisted. Shape validation is advisory — warnings are attached to metadata but the event is still persisted.
Two-Tier Validation
Structural (
validate_structural/1): Checks required fields and types. Rejects on failure.Shape (
validate_shape/1): Checks event-type-specific data field expectations. Returns warnings but does not reject.
Summary
Functions
Validates the data shape for the event type.
Validates required fields and types on an Event struct.
Functions
@spec validate_shape(AgentSessionManager.Core.Event.t()) :: [String.t()]
Validates the data shape for the event type.
Returns a list of warning strings. An empty list means the data matches the expected shape for this event type. Event types without shape rules pass unconditionally.
@spec validate_structural(AgentSessionManager.Core.Event.t()) :: :ok | {:error, AgentSessionManager.Core.Error.t()}
Validates required fields and types on an Event struct.
Returns :ok if all structural requirements are met, or
{:error, Error.t()} if a required field is missing or
has an invalid type.