domainforge_core/policy/
violation.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub enum Severity {
5 Error,
6 Warning,
7 Info,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
11pub struct Violation {
12 pub policy_name: String,
13 pub message: String,
14 pub severity: Severity,
15 pub context: serde_json::Value,
16}
17
18impl Violation {
19 pub fn new(
20 policy_name: impl Into<String>,
21 message: impl Into<String>,
22 severity: Severity,
23 ) -> Self {
24 Self {
25 policy_name: policy_name.into(),
26 message: message.into(),
27 severity,
28 context: serde_json::json!({}),
29 }
30 }
31
32 pub fn with_context(mut self, context: serde_json::Value) -> Self {
33 self.context = context;
34 self
35 }
36}