#[non_exhaustive]pub enum ValidationError {
Show 21 variants
EmptyField(&'static str),
FieldTooLong {
field: &'static str,
len: usize,
max: usize,
},
UnmappedNotPublishable(usize),
TypeUidMismatch {
type_uid: u64,
class_uid: u32,
activity_id: u8,
},
ClassUidMismatch(u32),
BadCategory(u8),
BadCharterType(u8),
BadSeverity(u8),
BadStatus(u8),
BadActivityId(u8),
StopReasonPairMismatch,
StopReasonCaptionMismatch {
id: u8,
expected_caption: &'static str,
actual_caption: String,
},
JcsUnsafeInteger {
field: &'static str,
value: u64,
},
OutOfSchemaRange {
field: &'static str,
value: u64,
max: u64,
},
ZeroTime,
UnknownStopReasonId(u8),
BadOcsfVersion(String),
BadFingerprint(&'static str),
PayloadTooManyProperties(usize),
TimeBeyondSchemaRange(u64),
TimeIsoMismatch {
time: u64,
time_iso: String,
expected_iso: String,
},
}Expand description
A structural validation failure.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EmptyField(&'static str)
A required string field was empty.
FieldTooLong
A string field exceeds the shipped schema’s maxLength — the event would pass Rust validation but fail the broker’s schema gate at publish (which fail-closes the session), splitting the two validators’ verdicts.
Fields
UnmappedNotPublishable(usize)
unmapped carries inbound-tolerance fields
that re-serialize to the top level, but the shipped schema
declares additionalProperties: false — such an event passes the
Rust validator yet fails the broker’s schema gate at publish
(which fail-closes the session). The tolerance is INBOUND-ONLY;
republishing an event that carries unmapped fields is refused
here so both validators agree.
TypeUidMismatch
type_uid doesn’t match class_uid * 100 + activity_id.
Fields
ClassUidMismatch(u32)
class_uid doesn’t match the class enum.
BadCategory(u8)
Event is not in the OCSF Application Activity category.
BadCharterType(u8)
Charter is not represented as an OCSF Regular File.
BadSeverity(u8)
Severity outside 1–6.
BadStatus(u8)
Status outside 0–2.
BadActivityId(u8)
Activity_id must be < 100 or the
class_uid × 100 + activity_id bijection collapses:
class_uid=9901, activity_id=100 produces the same
type_uid = 990200 as class_uid=9902, activity_id=0,
so downstream SIEM pipelines routing/aggregating by
type_uid mis-classify. Not currently reachable via the
builder (defaults 1), but OcsfEvent’s fields are all pub
and the struct is not #[non_exhaustive], so callers can
construct or mutate events directly, bypassing the builder;
enforce the bijection
invariant at validate time.
StopReasonPairMismatch
stop_reason caption present without id (or vice versa).
StopReasonCaptionMismatch
Stop_reason_id maps to a KNOWN StopReason variant,
but the accompanying caption does not match that variant’s
canonical caption. The two fields split downstream analytics
(SIEM pipelines that group by id disagree with dashboards that
group by caption) — reject the disagreement so both fields
mean the same thing.
Fields
JcsUnsafeInteger
A numeric field exceeds av_core::error::JCS_SAFE_MAX
(2^53) on the deserialize path. OcsfEventBuilder::build
already refuses values above the JCS-safe integer range, but
wire deserialization (serde_json::from_slice::<OcsfEvent>)
bypassed the guard — an issuer sending prompt_tokens = 2^53+1
would round-trip through JS-based auditors (JSON.parse) as a
silently-truncated value, losing 1 or more low bits and
breaking any receipt hash computed by JS consumers.
OutOfSchemaRange
A numeric field is out of its
schema-declared range. Currently only pruning_ratio_millis
(permille ratio, capped at 1000) enforces this, but the
variant is variant-generic so future range-bound fields can
reuse it. Parallel to JcsUnsafeInteger — build() and
validate_event (the deserialize backstop) both enforce the
bound, closing the emitter/validator drift the wire-side path
used to have.
ZeroTime
Timestamp is zero.
UnknownStopReasonId(u8)
Schema parity: stop_reason_id outside the schema enum
{0..=4, 90..=94, 99}.
BadOcsfVersion(String)
Schema parity: metadata.version must be the const “1.10.0”.
BadFingerprint(&'static str)
Schema parity: fingerprint constants (SHA-256/JCS/64-hex value).
PayloadTooManyProperties(usize)
Schema parity: payload maxProperties 512.
TimeBeyondSchemaRange(u64)
Schema parity: time_iso’s pattern requires a 4-digit year, so
epoch-ms beyond 9999-12-31 renders a caption the schema rejects.
TimeIsoMismatch
time_iso does not match the canonical ISO-8601 rendering of
time. The two fields are dual representations of one instant;
a mismatch means a signed/chained event names different times to
human auditors (caption) and machine tooling (epoch-ms). Same
class as the receipt’s issued_at/issued_at_iso cross-check.
Trait Implementations§
Source§impl Debug for ValidationError
impl Debug for ValidationError
Source§impl Display for ValidationError
impl Display for ValidationError
Source§impl Error for ValidationError
impl Error for ValidationError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for ValidationError
impl PartialEq for ValidationError
Source§fn eq(&self, other: &ValidationError) -> bool
fn eq(&self, other: &ValidationError) -> bool
self and other values to be equal, and is used by ==.impl Eq for ValidationError
impl StructuralPartialEq for ValidationError
Auto Trait Implementations§
impl Freeze for ValidationError
impl RefUnwindSafe for ValidationError
impl Send for ValidationError
impl Sync for ValidationError
impl Unpin for ValidationError
impl UnsafeUnpin for ValidationError
impl UnwindSafe for ValidationError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.