Skip to main content

ValidationError

Enum ValidationError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

§field: &'static str

Field path.

§len: usize

Observed length in chars.

§max: usize

Schema maxLength.

§

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

§type_uid: u64

Stated type uid.

§class_uid: u32

Stated class uid.

§activity_id: u8

Stated activity id.

§

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

§id: u8

Stated stop reason id.

§expected_caption: &'static str

Canonical caption for that id.

§actual_caption: String

Actual caption that was emitted with the id.

§

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.

Fields

§field: &'static str

Field name.

§value: u64

Offending value.

§

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.

Fields

§field: &'static str

Field name.

§value: u64

Offending value.

§max: u64

Declared inclusive max.

§

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.

Fields

§time: u64

Epoch-milliseconds timestamp.

§time_iso: String

Caption that was actually emitted.

§expected_iso: String

Canonical rendering of time.

Trait Implementations§

Source§

impl Debug for ValidationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ValidationError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for ValidationError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for ValidationError

Source§

fn eq(&self, other: &ValidationError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ValidationError

Source§

impl StructuralPartialEq for ValidationError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more