use alloc::string::{String, ToString};
use super::ValidationSeverity;
#[derive(Debug, Clone)]
pub struct StyleValidationIssue {
pub severity: ValidationSeverity,
pub message: String,
pub field: String,
pub suggestion: Option<String>,
}
impl StyleValidationIssue {
#[must_use]
pub fn new(
severity: ValidationSeverity,
field: &str,
message: &str,
suggestion: Option<&str>,
) -> Self {
Self {
severity,
message: message.to_string(),
field: field.to_string(),
suggestion: suggestion.map(ToString::to_string),
}
}
#[must_use]
pub fn error(field: &str, message: &str) -> Self {
Self::new(ValidationSeverity::Error, field, message, None)
}
#[must_use]
pub fn warning(field: &str, message: &str) -> Self {
Self::new(ValidationSeverity::Warning, field, message, None)
}
#[must_use]
pub fn info_with_suggestion(field: &str, message: &str, suggestion: &str) -> Self {
Self::new(ValidationSeverity::Info, field, message, Some(suggestion))
}
}