use serde_json::Value;
use super::{ValidationReport, Validator};
use crate::genome::schema::{GenomeSchemaVersion, CURRENT_SCHEMA_VERSION};
#[derive(Debug, Default, Clone, Copy)]
pub struct V3Validator;
impl V3Validator {
pub const fn new() -> Self {
Self
}
}
impl Validator for V3Validator {
fn schema_version(&self) -> GenomeSchemaVersion {
CURRENT_SCHEMA_VERSION
}
fn validate(&self, _genome: &Value) -> ValidationReport {
ValidationReport::new(CURRENT_SCHEMA_VERSION)
}
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
#[test]
fn reports_current_schema_version() {
let v = V3Validator::new();
assert_eq!(v.schema_version(), CURRENT_SCHEMA_VERSION);
}
#[test]
fn placeholder_returns_clean_report() {
let v = V3Validator::new();
let report = v.validate(&json!({ "anything": "goes" }));
assert!(report.is_clean());
assert_eq!(report.schema_version, Some(CURRENT_SCHEMA_VERSION));
}
}