oximedia_edit/edl/
validator.rs1use super::{Edl, EdlResult};
4
5#[derive(Debug, Clone, Default)]
7pub struct ValidationReport {
8 pub errors: Vec<String>,
10 pub warnings: Vec<String>,
12}
13
14impl ValidationReport {
15 #[must_use]
17 pub fn is_valid(&self) -> bool {
18 self.errors.is_empty()
19 }
20}
21
22#[derive(Debug, Default)]
24pub struct EdlValidator;
25
26impl EdlValidator {
27 #[must_use]
29 pub fn new() -> Self {
30 Self
31 }
32
33 pub fn validate(&self, edl: &Edl) -> EdlResult<ValidationReport> {
35 let mut report = ValidationReport::default();
36
37 if edl.title.is_empty() {
38 report.warnings.push("EDL has no title".to_string());
39 }
40
41 if edl.events.is_empty() {
42 report.warnings.push("EDL has no events".to_string());
43 }
44
45 let mut seen = std::collections::HashSet::new();
47 for event in &edl.events {
48 if !seen.insert(event.number) {
49 report
50 .errors
51 .push(format!("Duplicate event number: {}", event.number));
52 }
53 }
54
55 Ok(report)
56 }
57}