ass_core/analysis/styles/validation/
issue.rs1use alloc::string::{String, ToString};
8
9use super::ValidationSeverity;
10
11#[derive(Debug, Clone)]
13pub struct StyleValidationIssue {
14 pub severity: ValidationSeverity,
16 pub message: String,
18 pub field: String,
20 pub suggestion: Option<String>,
22}
23
24impl StyleValidationIssue {
25 #[must_use]
27 pub fn new(
28 severity: ValidationSeverity,
29 field: &str,
30 message: &str,
31 suggestion: Option<&str>,
32 ) -> Self {
33 Self {
34 severity,
35 message: message.to_string(),
36 field: field.to_string(),
37 suggestion: suggestion.map(ToString::to_string),
38 }
39 }
40
41 #[must_use]
43 pub fn error(field: &str, message: &str) -> Self {
44 Self::new(ValidationSeverity::Error, field, message, None)
45 }
46
47 #[must_use]
49 pub fn warning(field: &str, message: &str) -> Self {
50 Self::new(ValidationSeverity::Warning, field, message, None)
51 }
52
53 #[must_use]
55 pub fn info_with_suggestion(field: &str, message: &str, suggestion: &str) -> Self {
56 Self::new(ValidationSeverity::Info, field, message, Some(suggestion))
57 }
58}