use serde::Serialize;
#[derive(Serialize)]
pub struct ValidationResult {
pub(crate) valid: bool,
pub(crate) errors: Vec<ValidationError>,
pub(crate) warnings: Vec<ValidationWarning>,
}
#[derive(Serialize)]
pub struct ValidationError {
pub(crate) line: usize,
pub(crate) message: String,
#[serde(rename = "type")]
pub(crate) error_type: String,
}
#[derive(Serialize)]
pub struct ValidationWarning {
pub(crate) line: usize,
pub(crate) message: String,
pub(crate) rule: String,
}
impl ValidationResult {
pub(crate) fn new() -> Self {
Self {
valid: true,
errors: Vec::new(),
warnings: Vec::new(),
}
}
pub(crate) fn with_error(line: usize, message: String, error_type: String) -> Self {
Self {
valid: false,
errors: vec![ValidationError {
line,
message,
error_type,
}],
warnings: Vec::new(),
}
}
}