automapper_validation/display/views.rs
1//! The two worlds an issue can be addressed in.
2
3use crate::ValidationIssue;
4
5use super::IssueView;
6
7/// Locates issues by EDIFACT segment path — the world the validator works in.
8pub struct EdifactView;
9
10impl IssueView for EdifactView {
11 fn name(&self) -> &str {
12 "EDIFACT"
13 }
14 fn location(&self, issue: &ValidationIssue) -> Option<String> {
15 issue.field_path.clone()
16 }
17}
18
19/// Locates issues by BO4E field path.
20///
21/// Returns `None` for issues with no BO4E counterpart — envelope-level findings
22/// (UNH, UNT) and anything the mapping definitions do not cover. Roughly 11% of
23/// findings across the fixture corpus. Callers should say so rather than fall
24/// back to the EDIFACT path, which would put an EDIFACT path inside a BO4E view.
25pub struct Bo4eView;
26
27impl IssueView for Bo4eView {
28 fn name(&self) -> &str {
29 "BO4E"
30 }
31 fn location(&self, issue: &ValidationIssue) -> Option<String> {
32 issue.bo4e_path.clone()
33 }
34}