use crate::config::types::ServerConfig;
pub(super) fn validate_template_places(config: &ServerConfig, errors: &mut Vec<String>) {
let lys = config.auth.as_ref().and_then(|auth| auth.lys.as_ref());
if !config.templates.is_empty() && lys.is_some_and(|lys| !lys.templates.is_empty()) {
errors.push(
"templates are written once: at the top level or under [auth.lys], not both".to_owned(),
);
}
if config.templates.is_empty() {
return;
}
if config.auth.is_some() && lys.is_none() {
errors.push(
"templates: a gated exchange places services in Lys, write [auth.lys] or remove [auth]"
.to_owned(),
);
}
if config.auth.is_none() && config.templates.policy.is_some() {
errors.push(
"templates: roots and the record-template policy need [auth.lys.construction]; an \
open exchange takes the template array only"
.to_owned(),
);
}
}