Skip to main content

Validator

Trait Validator 

Source
pub trait Validator: Send + Sync {
    // Required method
    fn validate_batch(
        &self,
        segments: &[Segment<'_>],
        report: &mut ValidationReport,
    );

    // Provided method
    fn set_message_type(&mut self, _message_type: Option<&str>) { ... }
}
Expand description

Pluggable validator for parsed EDIFACT segments.

The primary contract is validate_batch, which processes an entire segment sequence and appends issues to a ValidationReport.

For validators that work segment-by-segment, the convenience function validate_each iterates over the slice and calls a per-segment closure, so you only need to implement validate_batch:

fn validate_batch(&self, segments: &[Segment<'_>], report: &mut ValidationReport) {
    validate_each(segments, report, |seg| {
        // return Ok(()) or Err(EdifactError::...)
        Ok(())
    });
}

Required Methods§

Source

fn validate_batch( &self, segments: &[Segment<'_>], report: &mut ValidationReport, )

Validate a full segment set and append issues to report.

Provided Methods§

Source

fn set_message_type(&mut self, _message_type: Option<&str>)

Configure message-type metadata for validators that support explicit scoping.

Implementors§