swift_mt_message/
validation_result.rs1use crate::ValidationError;
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct ValidationResult {
9 pub is_valid: bool,
10 pub errors: Vec<ValidationError>,
11 pub warnings: Vec<String>,
12}
13
14impl ValidationResult {
15 pub fn valid() -> Self {
16 Self {
17 is_valid: true,
18 errors: Vec::new(),
19 warnings: Vec::new(),
20 }
21 }
22
23 pub fn with_error(error: ValidationError) -> Self {
24 Self {
25 is_valid: false,
26 errors: vec![error],
27 warnings: Vec::new(),
28 }
29 }
30
31 pub fn with_errors(errors: Vec<ValidationError>) -> Self {
32 Self {
33 is_valid: errors.is_empty(),
34 errors,
35 warnings: Vec::new(),
36 }
37 }
38}