pub struct ValidationIssue {
pub severity: Severity,
pub category: Category,
pub source: IssueSource,
pub location: Location,
pub code: String,
pub message: String,
pub suggestion: Option<String>,
pub context: HashMap<String, String>,
pub additional_instances: Vec<Location>,
}Expand description
A single validation issue
Fields§
§severity: SeveritySeverity level
category: CategoryCategory of issue
source: IssueSourceAuthority that emitted this issue (XSD layer, prose rule, engine
internal). Inferred from code at construction time so the field
is always consistent with the code prefix — JS consumers can
filter on issue.source directly without re-implementing the
inference. Deserialised with a default so old reports without the
field round-trip cleanly.
location: LocationLocation where issue was found
code: StringError code (e.g., “ST2067-2:2020:8.3/FileNotFound”)
message: StringHuman-readable message
suggestion: Option<String>Suggestion for how to fix
context: HashMap<String, String>Additional context
additional_instances: Vec<Location>Other Locations when this issue represents an aggregation of
multiple identical-code occurrences (see
ValidationReport::aggregate). Empty for fresh, un-aggregated
issues. Skipped during serialisation when empty so the on-wire
shape stays back-compatible for callers that don’t aggregate.
Implementations§
Source§impl ValidationIssue
impl ValidationIssue
pub fn new( severity: Severity, category: Category, code: impl Into<String>, message: impl Into<String>, ) -> Self
Sourcepub fn from_code<C: ValidationCode>(code: C, message: impl Into<String>) -> Self
pub fn from_code<C: ValidationCode>(code: C, message: impl Into<String>) -> Self
Build a ValidationIssue directly from a typed ValidationCode,
reading severity + category from the catalogue rather than the
caller. Use this for any rule whose code lives in one of the
*_codes modules — the catalogue is the single source of truth
for severity and category. Pass the bare enum value:
use imferno_core::mxf::codes::St2067_2_2016;
let issue = ValidationIssue::from_code(
St2067_2_2016::AudioSampleRateUnsupported,
format!("got {hz} Hz"),
);Sourcepub fn instance_count(&self) -> usize
pub fn instance_count(&self) -> usize
Number of occurrences this issue represents. 1 for a fresh
issue, 1 + additional_instances.len() after aggregation.
JS consumers can compute this themselves as
1 + issue.additionalInstances.length — the field is the source
of truth, this method is a Rust-side convenience.
pub fn with_location(self, location: Location) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_context( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Trait Implementations§
Source§impl Clone for ValidationIssue
impl Clone for ValidationIssue
Source§fn clone(&self) -> ValidationIssue
fn clone(&self) -> ValidationIssue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more