use std::collections::HashSet;
use anyhow::Result;
use crate::{models::actions::FlowsModel, validate::ValidateTrait};
impl ValidateTrait for FlowsModel {
fn validate(&self) -> Result<()> {
for flow in &self.flows {
flow.validate()?;
}
let mut names: HashSet<&str> = HashSet::new();
for flow in &self.flows {
if !names.insert(flow.name.as_str()) {
anyhow::bail!("Duplicate action name '{}' across flows", flow.name);
}
}
Ok(())
}
}