use super::super::{BackendValidationError, ConfigError};
use crate::config::model::ComfyConfig;
pub fn validate_backend(backend_name: &str, cfg: &ComfyConfig) -> Result<(), ConfigError> {
if cfg.timeout_secs == 0 {
return Err(BackendValidationError::ZeroTimeout { backend: backend_name.to_owned() }.into());
}
if cfg.poll_timeout_secs == 0 {
return Err(
BackendValidationError::ZeroPollTimeout { backend: backend_name.to_owned() }.into()
);
}
if cfg.poll_interval_ms == 0 {
return Err(
BackendValidationError::ZeroPollInterval { backend: backend_name.to_owned() }.into()
);
}
if !matches!(cfg.base_url.scheme(), "http" | "https") {
return Err(BackendValidationError::UnsupportedScheme {
backend: backend_name.to_owned(),
scheme: cfg.base_url.scheme().to_owned(),
}
.into());
}
Ok(())
}